#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 */
scalar_t__ check_msr();
scalar_t__ close_msr();
scalar_t__ open_msr();
int /*<<< orphan*/ printf(char *);
scalar_t__ read_msr();
scalar_t__ write_msr();
int main() {
  int ret = 0;
  if (check_msr())
    return 1;
  if (open_msr())
    return 1;
  if (read_msr())
    return 1;
  if (write_msr())
    return 1;
  if (close_msr())
    return 1;
  printf("All OK!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <check_msr@plt>
cmp    $0x0,%rax
je     1193 <main+0x33>
movl   $0x1,-0x4(%rbp)
jmp    121a <main+0xba>
mov    $0x0,%al
call   1050 <open_msr@plt>
cmp    $0x0,%rax
je     11b0 <main+0x50>
movl   $0x1,-0x4(%rbp)
jmp    121a <main+0xba>
mov    $0x0,%al
call   1070 <read_msr@plt>
cmp    $0x0,%rax
je     11cd <main+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    121a <main+0xba>
mov    $0x0,%al
call   1080 <write_msr@plt>
cmp    $0x0,%rax
je     11ea <main+0x8a>
movl   $0x1,-0x4(%rbp)
jmp    121a <main+0xba>
mov    $0x0,%al
call   1060 <close_msr@plt>
cmp    $0x0,%rax
je     1207 <main+0xa7>
movl   $0x1,-0x4(%rbp)
jmp    121a <main+0xba>
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <check_msr@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11b0 <main+0x50>
xor    %eax,%eax
call   1050 <open_msr@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
xor    %eax,%eax
call   1070 <read_msr@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
xor    %eax,%eax
call   1080 <write_msr@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
xor    %eax,%eax
call   1060 <close_msr@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"All OK!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i64 (...) @check_msr()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 1, i32* %1
br label %24
6: ; preds = %0
%7 = call i64 (...) @open_msr()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %1
br label %24
10: ; preds = %6
%11 = call i64 (...) @read_msr()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 1, i32* %1
br label %24
14: ; preds = %10
%15 = call i64 (...) @write_msr()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 1, i32* %1
br label %24
18: ; preds = %14
%19 = call i64 (...) @close_msr()
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %1
br label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %24
24: ; preds = %22, %21, %17, %13, %9, %5
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@str = [8 x i8] c"All OK!\00"
define i32 @main() {
%1 = tail call i64 (...) @check_msr()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %17
3: ; preds = %0
%4 = tail call i64 (...) @open_msr()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = tail call i64 (...) @read_msr()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = tail call i64 (...) @write_msr()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = tail call i64 (...) @close_msr()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %12, %9, %6, %3, %0, %15
%18 = phi i32 [ 0, %15 ], [ 1, %0 ], [ 1, %3 ], [ 1, %6 ], [ 1, %9 ], [ 1, %12 ]
ret i32 %18
}