#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 */
struct timespec {
  long tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct timespec tim;
  tim.tv_sec = 0;
  tim.tv_nsec = 500000000L;
  int i = 0;
  while (i < 20) {
    if (i == 13) {
      break;
    }
    printf("%d\n", i);
    i++;
    nanosleep(&tim, NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x1dcd6500,-0x18(%rbp)
1d
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    1189 <main+0x69>
cmpl   $0xd,-0x1c(%rbp)
jne    115f <main+0x3f>
jmp    1189 <main+0x69>
mov    -0x1c(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed7(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %r14,%rdi
mov    $0xc,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i64 500000000, i64* %5
store i32 0, i32* %3
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 13
br i1 %11, label %12, label %13
12: ; preds = %9
br label %19
13: ; preds = %9
%14 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
br label %6
19: ; preds = %12, %6
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca <2 x i64>
%2 = bitcast <2 x i64>* %1 to %struct.timespec*
%3 = bitcast <2 x i64>* %1 to i8*
store <2 x i64> <i64 500000000, i64 0>, <2 x i64>* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%15 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%17 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 7)
%19 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%21 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 9)
%23 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 10)
%25 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 11)
%27 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 12)
%29 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
ret i32 0
}