#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ bar();
int /*<<< orphan*/ bla();
int /*<<< orphan*/ foo();
void dont_thread_4(int a, int nfirst) {
  int i = 0;
  int first;
  if (a)
    first = 0;
  else
    first = 1;
  do {
    if (first)
      foo();
    else
      bar();
    first = nfirst;
    bla();
  } while (i++ < 100);
}


x86 assembly (clang, -O0):
<dont_thread_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     115b <dont_thread_4+0x2b>
movl   $0x0,-0x10(%rbp)
jmp    1162 <dont_thread_4+0x32>
movl   $0x1,-0x10(%rbp)
jmp    1167 <dont_thread_4+0x37>
cmpl   $0x0,-0x10(%rbp)
je     117d <dont_thread_4+0x4d>
mov    $0x0,%al
call   1050 <foo@plt>
jmp    1184 <dont_thread_4+0x54>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <bla@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x64,%eax
jl     1167 <dont_thread_4+0x37>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dont_thread_4>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
xor    %eax,%eax
test   %edi,%edi
je     1142 <dont_thread_4+0x12>
call   1030 <bar@plt>
jmp    1147 <dont_thread_4+0x17>
call   1050 <foo@plt>
xor    %eax,%eax
call   1040 <bla@plt>
mov    $0x64,%ebp
jmp    1171 <dont_thread_4+0x41>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <bar@plt>
xor    %eax,%eax
call   1040 <bla@plt>
add    $0xffffffff,%ebp
je     117e <dont_thread_4+0x4e>
xor    %eax,%eax
test   %ebx,%ebx
je     1160 <dont_thread_4+0x30>
call   1050 <foo@plt>
jmp    1165 <dont_thread_4+0x35>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @dont_thread_4(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %6
br label %11
10: ; preds = %2
store i32 1, i32* %6
br label %11
11: ; preds = %10, %9
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @foo()
br label %19
17: ; preds = %12
%18 = call i32 (...) @bar()
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %4
store i32 %20, i32* %6
%21 = call i32 (...) @bla()
br label %22
22: ; preds = %19
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = icmp slt i32 %23, 100
br i1 %25, label %12, label %26
26: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @dont_thread_4(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @foo()
br label %8
6: ; preds = %2
%7 = tail call i32 (...) @bar()
br label %8
8: ; preds = %4, %6
%9 = tail call i32 (...) @bla()
%10 = icmp eq i32 %1, 0
br label %11
11: ; preds = %8, %17
%12 = phi i32 [ %19, %17 ], [ 1, %8 ]
br i1 %10, label %15, label %13
13: ; preds = %11
%14 = tail call i32 (...) @foo()
br label %17
15: ; preds = %11
%16 = tail call i32 (...) @bar()
br label %17
17: ; preds = %15, %13
%18 = tail call i32 (...) @bla()
%19 = add nuw nsw i32 %12, 1
%20 = icmp eq i32 %19, 101
br i1 %20, label %21, label %11
21: ; preds = %17
ret void
}