#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_2(int first) {
  int i = 0;
  do {
    bla();
    bla();
    bla();
    if (first)
      foo();
    else
      bar();
    first = 0;
    bla();
  } while (i++ < 100);
}


x86 assembly (clang, -O0):
<dont_thread_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <bla@plt>
mov    $0x0,%al
call   1040 <bla@plt>
mov    $0x0,%al
call   1040 <bla@plt>
cmpl   $0x0,-0x4(%rbp)
je     116d <dont_thread_2+0x3d>
mov    $0x0,%al
call   1050 <foo@plt>
jmp    1174 <dont_thread_2+0x44>
mov    $0x0,%al
call   1030 <bar@plt>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <bla@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x64,%eax
jl     1142 <dont_thread_2+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dont_thread_2>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
test   %ebx,%ebx
je     1155 <dont_thread_2+0x25>
call   1050 <foo@plt>
jmp    115a <dont_thread_2+0x2a>
call   1030 <bar@plt>
xor    %eax,%eax
call   1040 <bla@plt>
mov    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
call   1040 <bla@plt>
xor    %eax,%eax
call   1030 <bar@plt>
xor    %eax,%eax
call   1040 <bla@plt>
add    $0xffffffff,%ebx
jne    1170 <dont_thread_2+0x40>
pop    %rbx
ret

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

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