#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 /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strchr(char const *, char);
int /*<<< orphan*/ strtoul(char const *, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int zerossh_askpass(int /*<<< orphan*/, int /*<<< orphan*/);
int zerossh_setup(int, char const **);
int main(int argc, const char **argv) {
  const char *s;
  if (**argv != '/' && strchr(argv[0], '/') != NULL)
    fprintf(stderr, "You used a relative path -- ssh might not "
                    "locate the fd0ssh binary.\n");
  s = getenv("SSH_ASKPASS_FD");
  if (s != NULL)
    return zerossh_askpass(strtoul(s, NULL, 0), STDOUT_FILENO);
  if (argc == 1) {
    fprintf(stderr,
            "This program is not run from an interactive prompt, "
            "but rather from a script which utilizes it.\n"
            "Semantic call syntax:\n"
            "\t"
            "echo $password | %s <program> [options...]\n",
            *argv);
    return EXIT_FAILURE;
  }
  close(STDERR_FILENO);
  return zerossh_setup(argc, argv);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11cb <main+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11cb <main+0x5b>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xe73(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     120d <main+0x9d>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
call   1040 <zerossh_askpass@plt>
mov    %eax,-0x4(%rbp)
jmp    1263 <main+0xf3>
cmpl   $0x1,-0x8(%rbp)
jne    1246 <main+0xd6>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1263 <main+0xf3>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <zerossh_setup@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
cmpb   $0x2f,(%rdi)
je     11a6 <main+0x36>
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11a6 <main+0x36>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe98(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11d9 <main+0x69>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    0x2e26(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <zerossh_askpass@plt>
cmp    $0x1,%ebp
jne    1208 <main+0x98>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe63(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <zerossh_setup@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [69 x i8] c"You used a relative path -- ssh might not locate the fd0ssh binary.\0A\00"
@.str.1 = [15 x i8] c"SSH_ASKPASS_FD\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [163 x i8] c"This program is not run from an interactive prompt, but rather from a script which utilizes it.\0ASemantic call syntax:\0A\09echo $password | %s <program> [options...]\0A\00"
@EXIT_FAILURE = global i32 0
@STDERR_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 47
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32* @strchr(i8* %15, i8 signext 47)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %18, %12, %2
%22 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = call i32 @strtoul(i8* %26, i32* null, i32 0)
%28 = load i32, i32* @STDOUT_FILENO
%29 = call i32 @zerossh_askpass(i32 %27, i32 %28)
store i32 %29, i32* %3
br label %45
30: ; preds = %21
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %45
39: ; preds = %30
%40 = load i32, i32* @STDERR_FILENO
%41 = call i32 @close(i32 %40)
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @zerossh_setup(i32 %42, i8** %43)
store i32 %44, i32* %3
br label %45
45: ; preds = %39, %33, %25
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [69 x i8] c"You used a relative path -- ssh might not locate the fd0ssh binary.\0A\00"
@.str.1 = [15 x i8] c"SSH_ASKPASS_FD\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [163 x i8] c"This program is not run from an interactive prompt, but rather from a script which utilizes it.\0ASemantic call syntax:\0A\09echo $password | %s <program> [options...]\0A\00"
@EXIT_FAILURE = global i32 0
@STDERR_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 47
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32* @strchr(i8* %3, i8 signext 47)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %6, %2
%13 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call i32 @strtoul(i8* nocapture %13, i32* null, i32 0)
%17 = load i32, i32* @STDOUT_FILENO
%18 = tail call i32 @zerossh_askpass(i32 %16, i32 %17)
br label %30
19: ; preds = %12
%20 = icmp eq i32 %0, 1
br i1 %20, label %21, label %26
21: ; preds = %19
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %1
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
br label %30
26: ; preds = %19
%27 = load i32, i32* @STDERR_FILENO
%28 = tail call i32 @close(i32 %27)
%29 = tail call i32 @zerossh_setup(i32 %0, i8** %1)
br label %30
30: ; preds = %26, %21, %15
%31 = phi i32 [ %18, %15 ], [ %25, %21 ], [ %29, %26 ]
ret i32 %31
}