#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(void *);
int getopt(int, char **, char *);
void *optarg;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int thermal_info(char const *, char *, char const *);
int main(int argc, char *argv[]) {
  char *format = "%d";
  int interval = 1;
  bool snoop = false;
  const char *delimeter = " ";
  const char *prefix = "";
  int opt;
  while ((opt = getopt(argc, argv, "hsd:p:f:i:")) != -1) {
    switch (opt) {
    case 'h':
      printf("thermal [-h|-s|-d DELIMETER|-p PREFIX|-f FORMAT|-i INTERVAL]\n");
      return EXIT_SUCCESS;
    case 'd':
      delimeter = optarg;
      break;
    case 'p':
      prefix = optarg;
      break;
    case 's':
      snoop = true;
      break;
    case 'f':
      format = optarg;
      break;
    case 'i':
      interval = atoi(optarg);
      break;
    }
  }
  int exit_code;
  if (snoop)
    while ((exit_code = thermal_info(prefix, format, delimeter)) !=
           EXIT_FAILURE)
      sleep(interval);
  else
    exit_code = thermal_info(prefix, format, delimeter);
  return exit_code;
}


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)
lea    0xed3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xefc(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1256 <main+0x106>
mov    -0x34(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0xf,%eax
ja     1251 <main+0x101>
mov    -0x40(%rbp),%rax
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12b4 <main+0x164>
mov    0x2df7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1251 <main+0x101>
mov    0x2de4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1251 <main+0x101>
movl   $0x1,-0x20(%rbp)
jmp    1251 <main+0x101>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1251 <main+0x101>
mov    0x2db2(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1195 <main+0x45>
cmpl   $0x0,-0x20(%rbp)
je     129a <main+0x14a>
jmp    1265 <main+0x115>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <thermal_info@plt>
mov    %eax,-0x38(%rbp)
mov    0x2d58(%rip),%rcx
cmp    (%rcx),%eax
je     1295 <main+0x145>
mov    -0x1c(%rbp),%edi
call   1070 <sleep@plt>
jmp    1265 <main+0x115>
jmp    12ae <main+0x15e>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <thermal_info@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xeda(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xecd(%rip),%rax
mov    %rax,0x8(%rsp)
movl   $0x0,0x4(%rsp)
mov    $0x1,%r12d
lea    0xeb0(%rip),%r13
lea    0xeae(%rip),%r14
lea    0xe62(%rip),%r15
jmp    11a9 <main+0x59>
cmp    $0xffffffff,%eax
je     1237 <main+0xe7>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
lea    -0x64(%rax),%ecx
cmp    $0xf,%ecx
ja     11a0 <main+0x50>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x2e2a(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
jmp    11a9 <main+0x59>
mov    0x2e19(%rip),%rax
mov    (%rax),%r13
jmp    11a9 <main+0x59>
mov    0x2e0d(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
jmp    11a9 <main+0x59>
mov    0x2df9(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    11a9 <main+0x59>
movl   $0x1,0x4(%rsp)
jmp    11a9 <main+0x59>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
call   1060 <thermal_info@plt>
cmpl   $0x0,0x4(%rsp)
je     1228 <main+0xd8>
mov    0x2d7b(%rip),%r14
cmp    (%r14),%eax
je     1228 <main+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%edi
call   1070 <sleep@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <thermal_info@plt>
cmp    (%r14),%eax
jne    1270 <main+0x120>
jmp    1228 <main+0xd8>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"hsd:p:f:i:\00"
@.str.4 = [62 x i8] c"thermal [-h|-s|-d DELIMETER|-p PREFIX|-f FORMAT|-i INTERVAL]\0A\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 1, i32* %7
store i32 0, i32* %8
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %10
br label %13
13: ; preds = %33, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 %16, i32* %11
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %34
18: ; preds = %13
%19 = load i32, i32* %11
switch i32 %19, label %33 [
i32 104, label %20
i32 100, label %23
i32 112, label %25
i32 115, label %27
i32 102, label %28
i32 105, label %30
]
20: ; preds = %18
%21 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @EXIT_SUCCESS
store i32 %22, i32* %3
br label %56
23: ; preds = %18
%24 = load i8*, i8** @optarg
store i8* %24, i8** %9
br label %33
25: ; preds = %18
%26 = load i8*, i8** @optarg
store i8* %26, i8** %10
br label %33
27: ; preds = %18
store i32 1, i32* %8
br label %33
28: ; preds = %18
%29 = load i8*, i8** @optarg
store i8* %29, i8** %6
br label %33
30: ; preds = %18
%31 = load i8*, i8** @optarg
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %7
br label %33
33: ; preds = %18, %30, %28, %27, %25, %23
br label %13
34: ; preds = %13
%35 = load i32, i32* %8
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %34
br label %38
38: ; preds = %45, %37
%39 = load i8*, i8** %10
%40 = load i8*, i8** %6
%41 = load i8*, i8** %9
%42 = call i32 @thermal_info(i8* %39, i8* %40, i8* %41)
store i32 %42, i32* %12
%43 = load i32, i32* @EXIT_FAILURE
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = load i32, i32* %7
%47 = call i32 @sleep(i32 %46)
br label %38
48: ; preds = %38
br label %54
49: ; preds = %34
%50 = load i8*, i8** %10
%51 = load i8*, i8** %6
%52 = load i8*, i8** %9
%53 = call i32 @thermal_info(i8* %50, i8* %51, i8* %52)
store i32 %53, i32* %12
br label %54
54: ; preds = %49, %48
%55 = load i32, i32* %12
store i32 %55, i32* %3
br label %56
56: ; preds = %54, %20
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"hsd:p:f:i:\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
@str = [61 x i8] c"thermal [-h|-s|-d DELIMETER|-p PREFIX|-f FORMAT|-i INTERVAL]\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %32, %2
%4 = phi i8* [ %33, %32 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
%5 = phi i32 [ %10, %32 ], [ 1, %2 ]
%6 = phi i32 [ %15, %32 ], [ 0, %2 ]
%7 = phi i8* [ %19, %32 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %2 ]
%8 = phi i8* [ %22, %32 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %2 ]
br label %9
9: ; preds = %3, %34
%10 = phi i32 [ %5, %3 ], [ %36, %34 ]
%11 = phi i32 [ %6, %3 ], [ %15, %34 ]
%12 = phi i8* [ %7, %3 ], [ %19, %34 ]
%13 = phi i8* [ %8, %3 ], [ %22, %34 ]
br label %14
14: ; preds = %23, %9
%15 = phi i32 [ %11, %9 ], [ 1, %23 ]
%16 = phi i8* [ %12, %9 ], [ %19, %23 ]
%17 = phi i8* [ %13, %9 ], [ %22, %23 ]
br label %18
18: ; preds = %14, %28
%19 = phi i8* [ %16, %14 ], [ %29, %28 ]
%20 = phi i8* [ %17, %14 ], [ %22, %28 ]
br label %21
21: ; preds = %18, %30
%22 = phi i8* [ %20, %18 ], [ %31, %30 ]
br label %23
23: ; preds = %21, %23
%24 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
switch i32 %24, label %23 [
i32 -1, label %37
i32 104, label %25
i32 100, label %28
i32 112, label %30
i32 115, label %14
i32 102, label %32
i32 105, label %34
]
25: ; preds = %23
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%27 = load i32, i32* @EXIT_SUCCESS
br label %48
28: ; preds = %23
%29 = load i8*, i8** @optarg
br label %18
30: ; preds = %23
%31 = load i8*, i8** @optarg
br label %21
32: ; preds = %23
%33 = load i8*, i8** @optarg
br label %3
34: ; preds = %23
%35 = load i8*, i8** @optarg
%36 = tail call i32 @atoi(i8* %35)
br label %9
37: ; preds = %23
%38 = icmp eq i32 %15, 0
%39 = tail call i32 @thermal_info(i8* %22, i8* %4, i8* %19)
%40 = load i32, i32* @EXIT_FAILURE
%41 = icmp eq i32 %39, %40
%42 = select i1 %38, i1 true, i1 %41
br i1 %42, label %48, label %43
43: ; preds = %37, %43
%44 = tail call i32 @sleep(i32 %10)
%45 = tail call i32 @thermal_info(i8* %22, i8* %4, i8* %19)
%46 = load i32, i32* @EXIT_FAILURE
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %43
48: ; preds = %43, %37, %25
%49 = phi i32 [ %27, %25 ], [ %39, %37 ], [ %45, %43 ]
ret i32 %49
}