#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*/ printf(char *);
int /*<<< orphan*/ sleep(int);
void main() {
  while (1) {
    printf("\n\nstart sleep");
    sleep(2);
    printf("\nsleeped for a while");
    long i = 1;
    printf("\n\nstart work");
    while (++i <= 1147483647) {
    }
    printf("\nworked for a while");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <sleep@plt>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
movq   $0x1,-0x8(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
cmp    $0x446535ff,%rax
jg     117b <main+0x5b>
jmp    115e <main+0x3e>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1128 <main+0x8>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%r14
lea    0xed8(%rip),%r15
lea    0xee6(%rip),%r12
lea    0xeec(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <sleep@plt>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    1150 <main+0x30>

LLVM IR (-O0):
@.str = [14 x i8] c"\0A\0Astart sleep\00"
@.str.1 = [21 x i8] c"\0Asleeped for a while\00"
@.str.2 = [13 x i8] c"\0A\0Astart work\00"
@.str.3 = [20 x i8] c"\0Aworked for a while\00"
define void @main() {
%1 = alloca i64
br label %2
2: ; preds = %0, %12
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @sleep(i32 2)
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i64 1, i64* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %11, %2
%8 = load i64, i64* %1
%9 = add nsw i64 %8, 1
store i64 %9, i64* %1
%10 = icmp sle i64 %9, 1147483647
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %2
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0A\0Astart sleep\00"
@.str.1 = [21 x i8] c"\0Asleeped for a while\00"
@.str.2 = [13 x i8] c"\0A\0Astart work\00"
@.str.3 = [20 x i8] c"\0Aworked for a while\00"
define void @main() {
br label %1
1: ; preds = %0, %1
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @sleep(i32 2)
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %1
}