#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 checkpass_pam(char const *, char const *);
scalar_t__ strcmp(char const *, char *);
int checkpass(const char *user, const char *pass, const char *challenge) {
  if (!user || !pass)
    return 0;
  if (challenge) {
    if (strcmp(challenge, "pam") == 0)
      return checkpass_pam(user, pass);
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114a <checkpass+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    1156 <checkpass+0x36>
movl   $0x0,-0x4(%rbp)
jmp    119c <checkpass+0x7c>
cmpq   $0x0,-0x20(%rbp)
je     1195 <checkpass+0x75>
mov    -0x20(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <checkpass+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <checkpass_pam@plt>
mov    %eax,-0x4(%rbp)
jmp    119c <checkpass+0x7c>
jmp    1195 <checkpass+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkpass>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     114d <checkpass+0x2d>
mov    %rsi,%r14
test   %rsi,%rsi
je     114d <checkpass+0x2d>
test   %rdx,%rdx
je     114d <checkpass+0x2d>
mov    %rdi,%rbx
lea    0xec0(%rip),%rsi
mov    %rdx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1157 <checkpass+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <checkpass_pam@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"pam\00"
define i32 @checkpass(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %3
store i32 0, i32* %4
br label %27
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i8*, i8** %7
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8*, i8** %6
%24 = call i32 @checkpass_pam(i8* %22, i8* %23)
store i32 %24, i32* %4
br label %27
25: ; preds = %17
br label %26
26: ; preds = %25, %14
store i32 0, i32* %4
br label %27
27: ; preds = %26, %21, %13
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"pam\00"
define i32 @checkpass(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
%5 = icmp eq i8* %1, null
%6 = or i1 %4, %5
%7 = icmp eq i8* %2, null
%8 = or i1 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @checkpass_pam(i8* %0, i8* %1)
br label %14
14: ; preds = %9, %3, %12
%15 = phi i32 [ %13, %12 ], [ 0, %3 ], [ 0, %9 ]
ret i32 %15
}