void sleep(long millis) {
  int i = 0, j = 0, seconds = 0, milliseconds = 0;
  seconds = millis / 1000;
  milliseconds = millis % 1000;
  for (j = 0; j < seconds; j++) {
    for (i = 0; i < 30000; i++)
      ;
  }
  for (i = 0; i < milliseconds; i++) {
    for (j = 0; j < 30; j++)
      ;
  }
}


x86 assembly (clang, -O0):
<sleep>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1195 <sleep+0x95>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7530,-0xc(%rbp)
jge    1182 <sleep+0x82>
jmp    1174 <sleep+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <sleep+0x62>
jmp    1187 <sleep+0x87>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <sleep+0x4f>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11df <sleep+0xdf>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1e,-0x10(%rbp)
jge    11cc <sleep+0xcc>
jmp    11be <sleep+0xbe>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11af <sleep+0xaf>
jmp    11d1 <sleep+0xd1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119c <sleep+0x9c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sleep>:
ret

LLVM IR (-O0):
define void @sleep(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i64, i64* %2
%8 = sdiv i64 %7, 1000
%9 = trunc i64 %8 to i32
store i32 %9, i32* %5
%10 = load i64, i64* %2
%11 = srem i64 %10, 1000
%12 = trunc i64 %11 to i32
store i32 %12, i32* %6
store i32 0, i32* %4
br label %13
13: ; preds = %26, %1
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
store i32 0, i32* %3
br label %18
18: ; preds = %22, %17
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 30000
br i1 %20, label %21, label %25
21: ; preds = %18
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %18
25: ; preds = %18
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %13
29: ; preds = %13
store i32 0, i32* %3
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* %3
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %30
store i32 0, i32* %4
br label %35
35: ; preds = %39, %34
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 30
br i1 %37, label %38, label %42
38: ; preds = %35
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %35
42: ; preds = %35
br label %43
43: ; preds = %42
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %30
46: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @sleep(i64 %0) {
ret void
}