#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 */
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int i2c_read_word(int, int, int *);
int /*<<< orphan*/ mlx90614_reg_to_temp(int);
int /*<<< orphan*/ stdout;
int mlx90614_print_all(int file) {
  int res;
  uint16_t id[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  uint16_t ta;
  uint16_t tobj1;
  uint16_t tobj2;
  if ((res = i2c_read_word(file, (0x3c), &id[0])) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x3d), &id[1])) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x3e), &id[2])) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x3f), &id[3])) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x06), &ta)) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x07), &tobj1)) < 0) {
    return res;
  }
  if ((res = i2c_read_word(file, (0x08), &tobj2)) < 0) {
    return res;
  }
  fputs("All temperatures are in degree Celsius.\n", stdout);
  fprintf(stdout, "Device ID: %04x%04x%04x%04x\n", id[0], id[1], id[2], id[3]);
  fprintf(stdout,
          "Local Temperature: %.2lf\nRemote Temperature 1: %.2lf\nRemote "
          "Temperature 2: %.2lf\n",
          mlx90614_reg_to_temp(ta), mlx90614_reg_to_temp(tobj1),
          mlx90614_reg_to_temp(tobj2));
  return 0;
}


x86 assembly (clang, -O0):
<mlx90614_print_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x3c,%esi
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1193 <mlx90614_print_all+0x43>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
add    $0x4,%rdx
mov    $0x3d,%esi
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11bf <mlx90614_print_all+0x6f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
add    $0x8,%rdx
mov    $0x3e,%esi
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11eb <mlx90614_print_all+0x9b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
add    $0xc,%rdx
mov    $0x3f,%esi
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1217 <mlx90614_print_all+0xc7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
mov    $0x6,%esi
lea    -0x24(%rbp),%rdx
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    123f <mlx90614_print_all+0xef>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
mov    $0x7,%esi
lea    -0x28(%rbp),%rdx
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1267 <mlx90614_print_all+0x117>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
lea    -0x2c(%rbp),%rdx
call   1070 <i2c_read_word@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    128f <mlx90614_print_all+0x13f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1314 <mlx90614_print_all+0x1c4>
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
lea    0xd61(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <mlx90614_reg_to_temp@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%edi
call   1060 <mlx90614_reg_to_temp@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <mlx90614_reg_to_temp@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    %eax,%r8d
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlx90614_print_all>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
mov    $0x3c,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x3d,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    $0x3e,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
mov    $0x3f,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0x24(%rsp),%rdx
mov    %ebp,%edi
mov    $0x6,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0x20(%rsp),%rdx
mov    %ebp,%edi
mov    $0x7,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
lea    0x1c(%rsp),%rdx
mov    %ebp,%edi
mov    $0x8,%esi
call   1060 <i2c_read_word@plt>
test   %eax,%eax
js     1273 <mlx90614_print_all+0x133>
mov    0x2ddf(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xdf5(%rip),%rdi
call   1030 <fputs@plt>
mov    0x0(%rbp),%edi
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%r9d
lea    0xdfe(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%r14d
mov    0x24(%rsp),%edi
call   1050 <mlx90614_reg_to_temp@plt>
mov    %eax,%r15d
mov    0x20(%rsp),%edi
call   1050 <mlx90614_reg_to_temp@plt>
mov    %eax,%ebp
mov    0x1c(%rsp),%edi
call   1050 <mlx90614_reg_to_temp@plt>
lea    0xde7(%rip),%rsi
mov    %r14d,%edi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1275 <mlx90614_print_all+0x135>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"All temperatures are in degree Celsius.\0A\00"
@stdout = global i32 0
@.str.1 = [29 x i8] c"Device ID: %04x%04x%04x%04x\0A\00"
@.str.2 = [82 x i8] c"Local Temperature: %.2lf\0ARemote Temperature 1: %.2lf\0ARemote Temperature 2: %.2lf\0A\00"
define i32 @mlx90614_print_all(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = bitcast [4 x i32]* %5 to i8*
%10 = load i32, i32* %3
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%12 = call i32 @i2c_read_word(i32 %10, i32 60, i32* %11)
store i32 %12, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i32, i32* %4
store i32 %15, i32* %2
br label %76
16: ; preds = %1
%17 = load i32, i32* %3
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%19 = call i32 @i2c_read_word(i32 %17, i32 61, i32* %18)
store i32 %19, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i32, i32* %4
store i32 %22, i32* %2
br label %76
23: ; preds = %16
%24 = load i32, i32* %3
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%26 = call i32 @i2c_read_word(i32 %24, i32 62, i32* %25)
store i32 %26, i32* %4
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load i32, i32* %4
store i32 %29, i32* %2
br label %76
30: ; preds = %23
%31 = load i32, i32* %3
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%33 = call i32 @i2c_read_word(i32 %31, i32 63, i32* %32)
store i32 %33, i32* %4
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i32, i32* %4
store i32 %36, i32* %2
br label %76
37: ; preds = %30
%38 = load i32, i32* %3
%39 = call i32 @i2c_read_word(i32 %38, i32 6, i32* %6)
store i32 %39, i32* %4
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i32, i32* %4
store i32 %42, i32* %2
br label %76
43: ; preds = %37
%44 = load i32, i32* %3
%45 = call i32 @i2c_read_word(i32 %44, i32 7, i32* %7)
store i32 %45, i32* %4
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = load i32, i32* %4
store i32 %48, i32* %2
br label %76
49: ; preds = %43
%50 = load i32, i32* %3
%51 = call i32 @i2c_read_word(i32 %50, i32 8, i32* %8)
store i32 %51, i32* %4
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i32, i32* %4
store i32 %54, i32* %2
br label %76
55: ; preds = %49
%56 = load i32, i32* @stdout
%57 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = load i32, i32* @stdout
%59 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%60 = load i32, i32* %59
%61 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%62 = load i32, i32* %61
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%64 = load i32, i32* %63
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%66 = load i32, i32* %65
%67 = call i32 (i32, i8*, i32, i32, i32, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %62, i32 %64, i32 %66)
%68 = load i32, i32* @stdout
%69 = load i32, i32* %6
%70 = call i32 @mlx90614_reg_to_temp(i32 %69)
%71 = load i32, i32* %7
%72 = call i32 @mlx90614_reg_to_temp(i32 %71)
%73 = load i32, i32* %8
%74 = call i32 @mlx90614_reg_to_temp(i32 %73)
%75 = call i32 (i32, i8*, i32, i32, i32, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i32 %70, i32 %72, i32 %74)
store i32 0, i32* %2
br label %76
76: ; preds = %55, %53, %47, %41, %35, %28, %21, %14
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
@.str = [41 x i8] c"All temperatures are in degree Celsius.\0A\00"
@stdout = global i32 0
@.str.1 = [29 x i8] c"Device ID: %04x%04x%04x%04x\0A\00"
@.str.2 = [82 x i8] c"Local Temperature: %.2lf\0ARemote Temperature 1: %.2lf\0ARemote Temperature 2: %.2lf\0A\00"
define i32 @mlx90614_print_all(i32 %0) {
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [4 x i32]* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%11 = call i32 @i2c_read_word(i32 %0, i32 60, i32* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %51, label %13
13: ; preds = %1
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%15 = call i32 @i2c_read_word(i32 %0, i32 61, i32* %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %51, label %17
17: ; preds = %13
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%19 = call i32 @i2c_read_word(i32 %0, i32 62, i32* %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %51, label %21
21: ; preds = %17
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%23 = call i32 @i2c_read_word(i32 %0, i32 63, i32* %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %51, label %25
25: ; preds = %21
%26 = call i32 @i2c_read_word(i32 %0, i32 6, i32* %3)
%27 = icmp slt i32 %26, 0
br i1 %27, label %51, label %28
28: ; preds = %25
%29 = call i32 @i2c_read_word(i32 %0, i32 7, i32* %4)
%30 = icmp slt i32 %29, 0
br i1 %30, label %51, label %31
31: ; preds = %28
%32 = call i32 @i2c_read_word(i32 %0, i32 8, i32* %5)
%33 = icmp slt i32 %32, 0
br i1 %33, label %51, label %34
34: ; preds = %31
%35 = load i32, i32* @stdout
%36 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @stdout
%38 = load i32, i32* %10
%39 = load i32, i32* %14
%40 = load i32, i32* %18
%41 = load i32, i32* %22
%42 = call i32 (i32, i8*, i32, i32, i32, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* @stdout
%44 = load i32, i32* %3
%45 = call i32 @mlx90614_reg_to_temp(i32 %44)
%46 = load i32, i32* %4
%47 = call i32 @mlx90614_reg_to_temp(i32 %46)
%48 = load i32, i32* %5
%49 = call i32 @mlx90614_reg_to_temp(i32 %48)
%50 = call i32 (i32, i8*, i32, i32, i32, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %47, i32 %49)
br label %51
51: ; preds = %31, %28, %25, %21, %17, %13, %1, %34
%52 = phi i32 [ 0, %34 ], [ %11, %1 ], [ %15, %13 ], [ %19, %17 ], [ %23, %21 ], [ %26, %25 ], [ %29, %28 ], [ %32, %31 ]
ret i32 %52
}