#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 get_ticks(char *, int);
void milli_delay(int milli_sec) {
  int t = get_ticks(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/simowce/Code-analysis-of-orange-os/refs/heads/"
      "master/chapter8/IPC/kernel/clock.c",
      28);
  while (
      ((get_ticks(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/simowce/Code-analysis-of-orange-os/refs/"
            "heads/master/chapter8/IPC/kernel/clock.c",
            33) -
        t) *
       1000 / 100) < milli_sec) {
  }
}


x86 assembly (clang, -O0):
<milli_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x1c,%esi
call   1030 <get_ticks@plt>
mov    %eax,-0x8(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x21,%esi
call   1030 <get_ticks@plt>
sub    -0x8(%rbp),%eax
imul   $0x3e8,%eax,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    -0x4(%rbp),%eax
jge    115f <milli_delay+0x4f>
jmp    112f <milli_delay+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<milli_delay>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xee3(%rip),%r14
mov    %r14,%rdi
mov    $0x1c,%esi
call   1030 <get_ticks@plt>
mov    %eax,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x21,%esi
call   1030 <get_ticks@plt>
sub    %ebp,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
cmp    %ebx,%eax
jl     1130 <milli_delay+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/simowce/Code-analysis-of-orange-os/refs/heads/master/chapter8/IPC/kernel/clock.c\00"
define void @milli_delay(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @get_ticks(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 28)
store i32 %4, i32* %3
br label %5
5: ; preds = %13, %1
%6 = call i32 @get_ticks(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 33)
%7 = load i32, i32* %3
%8 = sub nsw i32 %6, %7
%9 = mul nsw i32 %8, 1000
%10 = sdiv i32 %9, 100
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %5
br label %5
14: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/simowce/Code-analysis-of-orange-os/refs/heads/master/chapter8/IPC/kernel/clock.c\00"
define void @milli_delay(i32 %0) {
%2 = tail call i32 @get_ticks(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 28)
br label %3
3: ; preds = %3, %1
%4 = tail call i32 @get_ticks(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 33)
%5 = sub nsw i32 %4, %2
%6 = mul nsw i32 %5, 10
%7 = icmp slt i32 %6, %0
br i1 %7, label %3, label %8
8: ; preds = %3
ret void
}