1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i386-apple-darwin -disable-cgp-branch-opts | FileCheck %s
3
4	%struct.DBC_t = type { i32, i8*, i16, %struct.DBC_t*, i8*, i8*, i8*, i8*, i8*, %struct.DBC_t*, i32, i32, i32, i32, i8*, i8*, i8*, i8*, i8*, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i32*, i8, i16, %struct.DRVOPT*, i16 }
5	%struct.DRVOPT = type { i16, i32, i8, %struct.DRVOPT* }
6	%struct.GENV_t = type { i32, i8*, i16, i8*, i8*, i32, i32, i32, i32, %struct.DBC_t*, i16 }
7	%struct.pthread_mutex_t = type { i32, [40 x i8] }
8@iodbcdm_global_lock = external global %struct.pthread_mutex_t		; <%struct.pthread_mutex_t*> [#uses=1]
9
10define i16 @SQLDriversW(i8* %henv, i16 zeroext  %fDir, i32* %szDrvDesc, i16 signext  %cbDrvDescMax, i16* %pcbDrvDesc, i32* %szDrvAttr, i16 signext  %cbDrvAttrMax, i16* %pcbDrvAttr) nounwind  {
11; CHECK-LABEL: SQLDriversW:
12; CHECK:       ## %bb.0: ## %entry
13; CHECK-NEXT:    pushl %ebp
14; CHECK-NEXT:    pushl %ebx
15; CHECK-NEXT:    pushl %edi
16; CHECK-NEXT:    pushl %esi
17; CHECK-NEXT:    subl $12, %esp
18; CHECK-NEXT:    movb $1, %al
19; CHECK-NEXT:    testb %al, %al
20; CHECK-NEXT:    je LBB0_1
21; CHECK-NEXT:  ## %bb.3: ## %bb28
22; CHECK-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
23; CHECK-NEXT:    movzwl {{[0-9]+}}(%esp), %ebx
24; CHECK-NEXT:    movzwl {{[0-9]+}}(%esp), %ebp
25; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %edi
26; CHECK-NEXT:    movw $-2, %si
27; CHECK-NEXT:    jne LBB0_6
28; CHECK-NEXT:  ## %bb.4: ## %bb37
29; CHECK-NEXT:    movw $0, 40(%edi)
30; CHECK-NEXT:    movb $1, %al
31; CHECK-NEXT:    testb %al, %al
32; CHECK-NEXT:    leal (,%ecx,4), %eax
33; CHECK-NEXT:    leal (,%ebx,4), %ecx
34; CHECK-NEXT:    subl $12, %esp
35; CHECK-NEXT:    movzwl %bp, %edx
36; CHECK-NEXT:    cwtl
37; CHECK-NEXT:    movswl %cx, %ecx
38; CHECK-NEXT:    pushl $87
39; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
40; CHECK-NEXT:    pushl %eax
41; CHECK-NEXT:    pushl $0
42; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
43; CHECK-NEXT:    pushl %ecx
44; CHECK-NEXT:    pushl $0
45; CHECK-NEXT:    pushl %edx
46; CHECK-NEXT:    pushl %edi
47; CHECK-NEXT:    calll _SQLDrivers_Internal
48; CHECK-NEXT:    addl $48, %esp
49; CHECK-NEXT:    movl %eax, %esi
50; CHECK-NEXT:    xorl %eax, %eax
51; CHECK-NEXT:    testb %al, %al
52; CHECK-NEXT:    je LBB0_1
53; CHECK-NEXT:  ## %bb.5:
54; CHECK-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
55; CHECK-NEXT:  LBB0_6: ## %done
56; CHECK-NEXT:    xorl %eax, %eax
57; CHECK-NEXT:    testb %al, %al
58; CHECK-NEXT:    je LBB0_7
59; CHECK-NEXT:  ## %bb.8: ## %bb167
60; CHECK-NEXT:    subl $12, %esp
61; CHECK-NEXT:    movl L_iodbcdm_global_lock$non_lazy_ptr, %eax
62; CHECK-NEXT:    pushl %eax
63; CHECK-NEXT:    calll _pthread_mutex_unlock
64; CHECK-NEXT:    addl $16, %esp
65; CHECK-NEXT:    movl %esi, %eax
66; CHECK-NEXT:    jmp LBB0_2
67; CHECK-NEXT:  LBB0_7: ## %bb150
68; CHECK-NEXT:    movswl %si, %eax
69; CHECK-NEXT:    subl $8, %esp
70; CHECK-NEXT:    movswl %cx, %ecx
71; CHECK-NEXT:    movswl %bx, %edx
72; CHECK-NEXT:    movzwl %bp, %esi
73; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
74; CHECK-NEXT:    pushl %ecx
75; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
76; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
77; CHECK-NEXT:    pushl %edx
78; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)
79; CHECK-NEXT:    pushl %esi
80; CHECK-NEXT:    pushl %edi
81; CHECK-NEXT:    pushl %eax
82; CHECK-NEXT:    pushl $1
83; CHECK-NEXT:    calll _trace_SQLDriversW
84; CHECK-NEXT:    addl $48, %esp
85; CHECK-NEXT:  LBB0_1: ## %bb
86; CHECK-NEXT:    xorl %eax, %eax
87; CHECK-NEXT:  LBB0_2: ## %bb
88; CHECK-NEXT:    addl $12, %esp
89; CHECK-NEXT:    popl %esi
90; CHECK-NEXT:    popl %edi
91; CHECK-NEXT:    popl %ebx
92; CHECK-NEXT:    popl %ebp
93; CHECK-NEXT:    retl
94entry:
95	%tmp12 = bitcast i8* %henv to %struct.GENV_t*		; <%struct.GENV_t*> [#uses=1]
96	br i1 true, label %bb28, label %bb
97bb:		; preds = %entry
98	ret i16 0
99bb28:		; preds = %entry
100	br i1 false, label %bb37, label %done
101bb37:		; preds = %bb28
102	%tmp46 = getelementptr %struct.GENV_t, %struct.GENV_t* %tmp12, i32 0, i32 10		; <i16*> [#uses=1]
103	store i16 0, i16* %tmp46, align 4
104	br i1 false, label %bb74, label %bb92
105bb74:		; preds = %bb37
106	br label %bb92
107bb92:		; preds = %bb74, %bb37
108	%tmp95180 = shl i16 %cbDrvAttrMax, 2		; <i16> [#uses=1]
109	%tmp100178 = shl i16 %cbDrvDescMax, 2		; <i16> [#uses=1]
110	%tmp113 = tail call i16 @SQLDrivers_Internal( i8* %henv, i16 zeroext  %fDir, i8* null, i16 signext  %tmp100178, i16* %pcbDrvDesc, i8* null, i16 signext  %tmp95180, i16* %pcbDrvAttr, i8 zeroext  87 )  nounwind 		; <i16> [#uses=1]
111	br i1 false, label %done, label %bb137
112bb137:		; preds = %bb92
113	ret i16 0
114done:		; preds = %bb92, %bb28
115	%retcode.0 = phi i16 [ -2, %bb28 ], [ %tmp113, %bb92 ]		; <i16> [#uses=2]
116	br i1 false, label %bb167, label %bb150
117bb150:		; preds = %done
118	%tmp157158 = sext i16 %retcode.0 to i32		; <i32> [#uses=1]
119	tail call void @trace_SQLDriversW( i32 1, i32 %tmp157158, i8* %henv, i16 zeroext  %fDir, i32* %szDrvDesc, i16 signext  %cbDrvDescMax, i16* %pcbDrvDesc, i32* %szDrvAttr, i16 signext  %cbDrvAttrMax, i16* %pcbDrvAttr ) nounwind
120	ret i16 0
121bb167:		; preds = %done
122	%tmp168 = tail call i32 @pthread_mutex_unlock( %struct.pthread_mutex_t* @iodbcdm_global_lock ) nounwind 		; <i32> [#uses=0]
123	ret i16 %retcode.0
124}
125
126declare i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*)
127
128declare i16 @SQLDrivers_Internal(i8*, i16 zeroext , i8*, i16 signext , i16*, i8*, i16 signext , i16*, i8 zeroext )  nounwind
129
130declare void @trace_SQLDriversW(i32, i32, i8*, i16 zeroext , i32*, i16 signext , i16*, i32*, i16 signext , i16*)
131