#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ sane_exit();
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ testsane(char *);
int main(int argc, char *argv[]) {
  if (argc != 2 && argc != 3) {
    fprintf(stderr, "Usage: %s devicename [hostname]\n", argv[0]);
    exit(0);
  }
  if (argc == 3) {
    char envbuf[1024];
    sprintf(envbuf, "SANE_NET_HOST=%s", argv[2]);
    putenv(envbuf);
  }
  fprintf(stderr,
          "This is a SANE test application.\n"
          "Now connecting to device %s.\n",
          argv[1]);
  testsane(argv[1]);
  sane_exit();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b0 <main+0x50>
cmpl   $0x3,-0x8(%rbp)
je     11b0 <main+0x50>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5c(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    11e1 <main+0x81>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe51(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <putenv@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe39(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <testsane@plt>
mov    $0x0,%al
call   1050 <sane_exit@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11d0 <main+0x70>
cmp    $0x3,%edi
jne    119a <main+0x3a>
mov    0x10(%rbx),%rdx
lea    0xe9a(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1040 <putenv@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x8(%rbx),%rdi
call   1030 <testsane@plt>
xor    %eax,%eax
call   1050 <sane_exit@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe1d(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s devicename [hostname]\0A\00"
@.str.1 = [17 x i8] c"SANE_NET_HOST=%s\00"
@.str.2 = [63 x i8] c"This is a SANE test application.\0ANow connecting to device %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %9, %2
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = call i32 @putenv(i8* %28)
br label %30
30: ; preds = %22, %19
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @testsane(i8* %38)
%40 = call i32 (...) @sane_exit()
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s devicename [hostname]\0A\00"
@.str.1 = [17 x i8] c"SANE_NET_HOST=%s\00"
@.str.2 = [63 x i8] c"This is a SANE test application.\0ANow connecting to device %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = and i32 %0, -2
%5 = icmp eq i32 %4, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %2
%12 = icmp eq i32 %0, 3
br i1 %12, label %13, label %19
13: ; preds = %11
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @putenv(i8* %14)
br label %19
19: ; preds = %13, %11
%20 = load i32, i32* @stderr
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %21
%25 = call i32 @testsane(i8* %24)
%26 = call i32 (...) @sane_exit()
ret i32 0
}