#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 */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ run_suite(int, double, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int i, n;
  double baseline_power_consumption;
  char command[1024];
  if (argc < 4) {
    perror("[-] Usage: energy_analyser <av_pow> <n> <command_line> \n");
    exit(1);
  }
  baseline_power_consumption = atof(argv[1]);
  n = atoi(argv[2]);
  strcpy(command, argv[3]);
  for (i = 4; i < argc; i++) {
    strcat(command, " ");
    strcat(command, argv[i]);
  }
  run_suite(n, baseline_power_consumption, command);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11a9 <main+0x39>
lea    0xe66(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <strcpy@plt>
movl   $0x4,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    122b <main+0xbb>
lea    -0x420(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e6 <main+0x76>
mov    -0x18(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
lea    -0x420(%rbp),%rsi
call   1050 <run_suite@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
cmp    $0x3,%edi
jle    1227 <main+0xb7>
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%r12),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%r12),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
cmp    $0x4,%ebp
je     1200 <main+0x90>
mov    %ebp,%r13d
mov    $0x4,%ebx
lea    0xe6b(%rip),%r15
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    (%r12,%rbx,8),%rsi
mov    %rbp,%rdi
call   1080 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11e0 <main+0x70>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
movsd  0x8(%rsp),%xmm0
call   1050 <run_suite@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd2(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"[-] Usage: energy_analyser <av_pow> <n> <command_line> \0A\00"
@.str.1 = [2 x i8] c" \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 double
%9 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call double @atof(i8* %18)
store double %19, double* %8
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @strcpy(i8* %24, i8* %27)
store i32 4, i32* %6
br label %29
29: ; preds = %43, %15
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %46
33: ; preds = %29
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @strcat(i8* %36, i8* %41)
br label %43
43: ; preds = %33
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %29
46: ; preds = %29
%47 = load i32, i32* %7
%48 = load double, double* %8
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = call i32 @run_suite(i32 %47, double %48, i8* %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"[-] Usage: energy_analyser <av_pow> <n> <command_line> \0A\00"
@.str.1 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call double @atof(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = call i32 @strcpy(i8* %4, i8* %17)
%19 = icmp eq i32 %0, 4
br i1 %19, label %30, label %20
20: ; preds = %9
%21 = zext i32 %0 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 4, %20 ], [ %28, %22 ]
%24 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds i8*, i8** %1, i64 %23
%26 = load i8*, i8** %25
%27 = call i32 @strcat(i8* %4, i8* %26)
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, %21
br i1 %29, label %30, label %22
30: ; preds = %22, %9
%31 = call i32 @run_suite(i32 %15, double %12, i8* %4)
ret i32 0
}