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

/* Variables and functions */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
double gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *, double const, double const,
                          double const, ...);
int /*<<< orphan*/ usage(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 5) {
    usage(argv[0], "wrong number of parameters");
  }
  struct timeval tv;
  gettimeofday(&tv, NULL);
  long t0 = 1000000L * tv.tv_sec + tv.tv_usec;
  const double A = atof(argv[1]);
  const double B = atof(argv[2]);
  const int N = atoi(argv[3]);
  if (A >= B) {
    usage(argv[0], "B must be > A");
  }
  if (N <= 0) {
    usage(argv[0], "N must be > 0");
  }
  printf("started: pid=%8d ID=%-8s A=%8.6lf B=%8.6lf N=%8d\n\n", getpid(),
         argv[4], A, B, N);
  double result = gettimeofday(&tv, NULL);
  long t1 = 1000000L * tv.tv_sec + tv.tv_usec;
  long delta_t = t1 - t0;
  printf("pid=%8d ID=%-8s t=%8ld A=%8.6lf B=%8.6lf N=%8d -> result=%8.6f\n\n",
         getpid(), argv[4], delta_t, A, B, N, result);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11a3 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe62(%rip),%rsi
call   1070 <usage@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
imul   $0xf4240,-0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x3c(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jb     1217 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe09(%rip),%rsi
call   1070 <usage@plt>
cmpl   $0x0,-0x3c(%rbp)
jg     1234 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <usage@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x3c(%rbp),%xmm2
lea    0xddc(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  %xmm0,-0x48(%rbp)
imul   $0xf4240,-0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
cvtsi2sdq -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
mov    -0x3c(%rbp),%ecx
movsd  -0x48(%rbp),%xmm3
lea    0xdaa(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
je     1193 <main+0x23>
mov    (%rbx),%rdi
lea    0xe72(%rip),%rsi
call   1070 <usage@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x18(%rsp),%r15
mov    0x20(%rsp),%r14
mov    0x8(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r12d
movsd  0x10(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
jb     11f0 <main+0x80>
mov    (%rbx),%rdi
lea    0xe30(%rip),%rsi
call   1070 <usage@plt>
test   %r12d,%r12d
jg     1204 <main+0x94>
mov    (%rbx),%rdi
lea    0xe2a(%rip),%rsi
call   1070 <usage@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x20(%rbx),%rdx
cvtsi2sd %r12d,%xmm2
lea    0xe1c(%rip),%rdi
mov    %eax,%esi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x3,%al
call   1050 <printf@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x18(%rsp),%rax
sub    %r15,%rax
mov    0x20(%rsp),%rcx
sub    %r14,%rcx
imul   $0xf4240,%rax,%rbp
add    %rcx,%rbp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x20(%rbx),%rdx
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
lea    0xdf4(%rip),%rdi
mov    %eax,%esi
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mov    %r12d,%ecx
movsd  0x28(%rsp),%xmm3
mov    $0x4,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [27 x i8] c"wrong number of parameters\00"
@.str.1 = [14 x i8] c"B must be > A\00"
@.str.2 = [14 x i8] c"N must be > 0\00"
@.str.3 = [51 x i8] c"started: pid=%8d ID=%-8s A=%8.6lf B=%8.6lf N=%8d\0A\0A\00"
@.str.4 = [65 x i8] c"pid=%8d ID=%-8s t=%8ld A=%8.6lf B=%8.6lf N=%8d -> result=%8.6f\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 5
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @usage(i8* %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %16, %2
%22 = call double @gettimeofday(%struct.timeval* %6, i32* null)
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%24 = load i64, i64* %23
%25 = mul nsw i64 1000000, %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%27 = load i64, i64* %26
%28 = add nsw i64 %25, %27
store i64 %28, i64* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call double @atof(i8* %31)
store double %32, double* %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call double @atof(i8* %35)
store double %36, double* %9
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %10
%41 = load double, double* %8
%42 = load double, double* %9
%43 = fcmp oge double %41, %42
br i1 %43, label %44, label %49
44: ; preds = %21
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @usage(i8* %47, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %49
49: ; preds = %44, %21
%50 = load i32, i32* %10
%51 = icmp sle i32 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @usage(i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %57
57: ; preds = %52, %49
%58 = call i32 (...) @getpid()
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 4
%61 = load i8*, i8** %60
%62 = load double, double* %8
%63 = load double, double* %9
%64 = load i32, i32* %10
%65 = sitofp i32 %64 to double
%66 = call i32 (i8*, i32, i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %58, i8* %61, double %62, double %63, double %65)
%67 = call double @gettimeofday(%struct.timeval* %6, i32* null)
store double %67, double* %11
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%69 = load i64, i64* %68
%70 = mul nsw i64 1000000, %69
%71 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%72 = load i64, i64* %71
%73 = add nsw i64 %70, %72
store i64 %73, i64* %12
%74 = load i64, i64* %12
%75 = load i64, i64* %7
%76 = sub nsw i64 %74, %75
store i64 %76, i64* %13
%77 = call i32 (...) @getpid()
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 4
%80 = load i8*, i8** %79
%81 = load i64, i64* %13
%82 = sitofp i64 %81 to double
%83 = load double, double* %8
%84 = load double, double* %9
%85 = load i32, i32* %10
%86 = load double, double* %11
%87 = call i32 (i8*, i32, i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), i32 %77, i8* %80, double %82, double %83, double %84, i32 %85, double %86)
%88 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [27 x i8] c"wrong number of parameters\00"
@.str.1 = [14 x i8] c"B must be > A\00"
@.str.2 = [14 x i8] c"N must be > 0\00"
@.str.3 = [51 x i8] c"started: pid=%8d ID=%-8s A=%8.6lf B=%8.6lf N=%8d\0A\0A\00"
@.str.4 = [65 x i8] c"pid=%8d ID=%-8s t=%8ld A=%8.6lf B=%8.6lf N=%8d -> result=%8.6f\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = icmp eq i32 %0, 5
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @usage(i8* %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = bitcast %struct.timeval* %3 to i8*
%10 = call double @gettimeofday(%struct.timeval* %3, i32* null)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%14 = load i64, i64* %13
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call double @atof(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call double @atof(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = fcmp ult double %17, %20
br i1 %24, label %28, label %25
25: ; preds = %8
%26 = load i8*, i8** %1
%27 = tail call i32 @usage(i8* %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %8
%29 = icmp slt i32 %23, 1
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %1
%32 = tail call i32 @usage(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %30, %28
%34 = tail call i32 (...) @getpid()
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
%37 = sitofp i32 %23 to double
%38 = tail call i32 (i8*, i32, i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %34, i8* %36, double %17, double %20, double %37)
%39 = call double @gettimeofday(%struct.timeval* %3, i32* null)
%40 = load i64, i64* %11
%41 = load i64, i64* %13
%42 = sub i64 %40, %12
%43 = mul i64 %42, 1000000
%44 = sub i64 %41, %14
%45 = add i64 %44, %43
%46 = tail call i32 (...) @getpid()
%47 = load i8*, i8** %35
%48 = sitofp i64 %45 to double
%49 = tail call i32 (i8*, i32, i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), i32 %46, i8* %47, double %48, double %17, double %20, i32 %23, double %39)
%50 = tail call i32 @exit(i32 0)
unreachable
}