#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 /*<<< orphan*/ DBG(int, char *);
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ pixma_adf_is_ready();
int /*<<< orphan*/ pixma_close();
int /*<<< orphan*/ pixma_init();
scalar_t__ pixma_open();
int /*<<< orphan*/ stderr;
int testAdf() {
  int code = EXIT_FAILURE;
  if (pixma_open() < 0) {
    fprintf(stderr, "Could not connect to scanner\n");
    return code;
  }
  pixma_init();
  if (pixma_adf_is_ready()) {
    DBG(1, "There is a sheet in the ADF\n");
    code = EXIT_SUCCESS;
  } else {
    DBG(1, "There is NOT a sheet in the ADF\n");
  }
  pixma_close();
  return code;
}


x86 assembly (clang, -O0):
<testAdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1080 <pixma_open@plt>
cmp    $0x0,%rax
jge    11a5 <testAdf+0x45>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <testAdf+0x9d>
mov    $0x0,%al
call   1070 <pixma_init@plt>
mov    $0x0,%al
call   1040 <pixma_adf_is_ready@plt>
cmp    $0x0,%rax
je     11df <testAdf+0x7f>
mov    $0x1,%edi
lea    0xe55(%rip),%rsi
call   1030 <DBG@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    11f0 <testAdf+0x90>
mov    $0x1,%edi
lea    0xe50(%rip),%rsi
call   1030 <DBG@plt>
mov    $0x0,%al
call   1060 <pixma_close@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testAdf>:
push   %rbx
mov    0x2e70(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1080 <pixma_open@plt>
test   %rax,%rax
js     11a5 <testAdf+0x45>
xor    %eax,%eax
call   1070 <pixma_init@plt>
xor    %eax,%eax
call   1040 <pixma_adf_is_ready@plt>
test   %rax,%rax
je     11bc <testAdf+0x5c>
lea    0xe8e(%rip),%rsi
mov    $0x1,%edi
call   1030 <DBG@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%ebx
jmp    11cd <testAdf+0x6d>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d4 <testAdf+0x74>
lea    0xe78(%rip),%rsi
mov    $0x1,%edi
call   1030 <DBG@plt>
xor    %eax,%eax
call   1060 <pixma_close@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"Could not connect to scanner\0A\00"
@.str.1 = [29 x i8] c"There is a sheet in the ADF\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [33 x i8] c"There is NOT a sheet in the ADF\0A\00"
define i32 @testAdf() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @EXIT_FAILURE
store i32 %3, i32* %2
%4 = call i64 (...) @pixma_open()
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
store i32 %9, i32* %1
br label %22
10: ; preds = %0
%11 = call i32 (...) @pixma_init()
%12 = call i64 (...) @pixma_adf_is_ready()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @DBG(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_SUCCESS
store i32 %16, i32* %2
br label %19
17: ; preds = %10
%18 = call i32 @DBG(i32 1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = call i32 (...) @pixma_close()
%21 = load i32, i32* %2
store i32 %21, i32* %1
br label %22
22: ; preds = %19, %6
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"Could not connect to scanner\0A\00"
@.str.1 = [29 x i8] c"There is a sheet in the ADF\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [33 x i8] c"There is NOT a sheet in the ADF\0A\00"
define i32 @testAdf() {
%1 = load i32, i32* @EXIT_FAILURE
%2 = tail call i64 (...) @pixma_open()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %19
7: ; preds = %0
%8 = tail call i32 (...) @pixma_init()
%9 = tail call i64 (...) @pixma_adf_is_ready()
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @DBG(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_SUCCESS
br label %16
14: ; preds = %7
%15 = tail call i32 @DBG(i32 1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %13, %11 ], [ %1, %14 ]
%18 = tail call i32 (...) @pixma_close()
br label %19
19: ; preds = %16, %4
%20 = phi i32 [ %1, %4 ], [ %17, %16 ]
ret i32 %20
}