#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 timeval {
  scalar_t__ tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int atoi(char const *);
int /*<<< orphan*/ draw(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
int main(int argc, const char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s WIDTH HEIGHT\n", argv[0]);
    return 1;
  }
  int width = atoi(argv[1]);
  int height = atoi(argv[2]);
  struct timeval tv1, tv2;
  gettimeofday(&tv1, 0);
  draw(width, height);
  gettimeofday(&tv2, 0);
  printf("Time for draw: %f ms\n",
         (double)(tv2.tv_usec - tv1.tv_usec) / 1000 +
             (double)(tv2.tv_sec - tv2.tv_sec) * 1000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1198 <main+0x48>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe81(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1222 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <draw@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xe12(%rip),%xmm0
divsd  %xmm0,%xmm1
mov    -0x38(%rbp),%rax
sub    -0x38(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xdf9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11c6 <main+0x76>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <draw@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x8(%rsp),%rax
sub    0x18(%rsp),%rax
cvtsi2sd %rax,%xmm1
divsd  0xe50(%rip),%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
jmp    11e3 <main+0x93>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe2f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s WIDTH HEIGHT\0A\00"
@.str.1 = [22 x i8] c"Time for draw: %f ms\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %47
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
%27 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @draw(i32 %28, i32 %29)
%31 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%33 = load i64, i64* %32
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%35 = load i64, i64* %34
%36 = sub nsw i64 %33, %35
%37 = sitofp i64 %36 to double
%38 = fdiv double %37, 1.000000e+03
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%40 = load i64, i64* %39
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%42 = load i64, i64* %41
%43 = sub nsw i64 %40, %42
%44 = sitofp i64 %43 to double
%45 = call double @llvm.fmuladd.f64(double %44, double 1.000000e+03, double %38)
%46 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %45)
store i32 0, i32* %3
br label %47
47: ; preds = %18, %12
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s WIDTH HEIGHT\0A\00"
@.str.1 = [22 x i8] c"Time for draw: %f ms\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = icmp eq i32 %0, 3
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %31
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = bitcast %struct.timeval* %3 to i8*
%18 = bitcast %struct.timeval* %4 to i8*
%19 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%20 = call i32 @draw(i32 %13, i32 %16)
%21 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%23 = load i64, i64* %22
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%25 = load i64, i64* %24
%26 = sub nsw i64 %23, %25
%27 = sitofp i64 %26 to double
%28 = fdiv double %27, 1.000000e+03
%29 = fadd double %28, 0.000000e+00
%30 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %29)
br label %31
31: ; preds = %10, %6
%32 = phi i32 [ 1, %6 ], [ 0, %10 ]
ret i32 %32
}