#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 */
typedef void pass_session;

/* Variables and functions */
int /*<<< orphan*/ av_free(char *);
int /*<<< orphan*/ av_log(int, char *, long);
char *av_stradd(void *, char const *, char const *, void *, ...);
void *pass_find_session(void *, char *);
struct pass_session *pass_get_password(struct pass_session *passd,
                                       const char *host, const char *user) {
  struct pass_session *fts = ((void *)0);
  char *account;
  if (passd == ((void *)0)) {
    return ((void *)0);
  }
  if (fts == ((void *)0)) {
    account = av_stradd(((void *)0), user, "@", host, ((void *)0));
    fts = pass_find_session(passd, account);
    av_free(account);
  }
  if (fts == ((void *)0)) {
    account = av_stradd(((void *)0), user, "@", ((void *)0));
    fts = pass_find_session(passd, account);
    av_free(account);
  }
  if (fts == ((void *)0)) {
    account = av_stradd(((void *)0), "@", host, ((void *)0));
    fts = pass_find_session(passd, account);
    av_free(account);
  }
  av_log(004, "passwords: fts=%lx", (long)fts);
  return fts;
}


x86 assembly (clang, -O0):
<pass_get_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <pass_get_password+0x34>
movq   $0x0,-0x8(%rbp)
jmp    125c <pass_get_password+0x11c>
cmpq   $0x0,-0x28(%rbp)
jne    11bb <pass_get_password+0x7b>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
lea    0xe6d(%rip),%rdx
mov    %r8,%rdi
mov    $0x0,%al
call   1030 <av_stradd@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <pass_find_session@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <av_free@plt>
cmpq   $0x0,-0x28(%rbp)
jne    11fd <pass_get_password+0xbd>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe2b(%rip),%rdx
mov    %rcx,%rdi
mov    $0x0,%al
call   1030 <av_stradd@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <pass_find_session@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <av_free@plt>
cmpq   $0x0,-0x28(%rbp)
jne    123f <pass_get_password+0xff>
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xde9(%rip),%rsi
mov    %rcx,%rdi
mov    $0x0,%al
call   1030 <av_stradd@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <pass_find_session@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <av_free@plt>
mov    -0x28(%rbp),%rdx
mov    $0x4,%edi
lea    0xdb3(%rip),%rsi
call   1060 <av_log@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pass_get_password>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
je     1209 <pass_get_password+0xc9>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9e(%rip),%rdx
xor    %edi,%edi
mov    %r12,%rsi
mov    %r14,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1030 <av_stradd@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <pass_find_session@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1050 <av_free@plt>
test   %r13,%r13
jne    11f3 <pass_get_password+0xb3>
lea    0xe67(%rip),%rdx
xor    %edi,%edi
mov    %r12,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <av_stradd@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <pass_find_session@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1050 <av_free@plt>
test   %r13,%r13
jne    11f3 <pass_get_password+0xb3>
lea    0xe34(%rip),%rsi
xor    %edi,%edi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <av_stradd@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <pass_find_session@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1050 <av_free@plt>
lea    0xe08(%rip),%rsi
mov    $0x4,%edi
mov    %r13,%rdx
call   1060 <av_log@plt>
jmp    120c <pass_get_password+0xcc>
xor    %r13d,%r13d
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pass_session = type opaque
@.str = [2 x i8] c"@\00"
@.str.1 = [19 x i8] c"passwords: fts=%lx\00"
define %struct.pass_session* @pass_get_password(%struct.pass_session* %0, i8* %1, i8* %2) {
%4 = alloca %struct.pass_session*
%5 = alloca %struct.pass_session*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.pass_session*
%9 = alloca i8*
store %struct.pass_session* %0, %struct.pass_session** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store %struct.pass_session* null, %struct.pass_session** %8
%10 = load %struct.pass_session*, %struct.pass_session** %5
%11 = icmp eq %struct.pass_session* %10, null
br i1 %11, label %12, label %13
12: ; preds = %3
store %struct.pass_session* null, %struct.pass_session** %4
br label %58
13: ; preds = %3
%14 = load %struct.pass_session*, %struct.pass_session** %8
%15 = icmp eq %struct.pass_session* %14, null
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = load i8*, i8** %6
%19 = call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %18, i8* null)
store i8* %19, i8** %9
%20 = load %struct.pass_session*, %struct.pass_session** %5
%21 = bitcast %struct.pass_session* %20 to i8*
%22 = load i8*, i8** %9
%23 = call i8* @pass_find_session(i8* %21, i8* %22)
%24 = bitcast i8* %23 to %struct.pass_session*
store %struct.pass_session* %24, %struct.pass_session** %8
%25 = load i8*, i8** %9
%26 = call i32 @av_free(i8* %25)
br label %27
27: ; preds = %16, %13
%28 = load %struct.pass_session*, %struct.pass_session** %8
%29 = icmp eq %struct.pass_session* %28, null
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = load i8*, i8** %7
%32 = call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* null)
store i8* %32, i8** %9
%33 = load %struct.pass_session*, %struct.pass_session** %5
%34 = bitcast %struct.pass_session* %33 to i8*
%35 = load i8*, i8** %9
%36 = call i8* @pass_find_session(i8* %34, i8* %35)
%37 = bitcast i8* %36 to %struct.pass_session*
store %struct.pass_session* %37, %struct.pass_session** %8
%38 = load i8*, i8** %9
%39 = call i32 @av_free(i8* %38)
br label %40
40: ; preds = %30, %27
%41 = load %struct.pass_session*, %struct.pass_session** %8
%42 = icmp eq %struct.pass_session* %41, null
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = load i8*, i8** %6
%45 = call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %44, i8* null)
store i8* %45, i8** %9
%46 = load %struct.pass_session*, %struct.pass_session** %5
%47 = bitcast %struct.pass_session* %46 to i8*
%48 = load i8*, i8** %9
%49 = call i8* @pass_find_session(i8* %47, i8* %48)
%50 = bitcast i8* %49 to %struct.pass_session*
store %struct.pass_session* %50, %struct.pass_session** %8
%51 = load i8*, i8** %9
%52 = call i32 @av_free(i8* %51)
br label %53
53: ; preds = %43, %40
%54 = load %struct.pass_session*, %struct.pass_session** %8
%55 = ptrtoint %struct.pass_session* %54 to i64
%56 = call i32 @av_log(i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %55)
%57 = load %struct.pass_session*, %struct.pass_session** %8
store %struct.pass_session* %57, %struct.pass_session** %4
br label %58
58: ; preds = %53, %12
%59 = load %struct.pass_session*, %struct.pass_session** %4
ret %struct.pass_session* %59
}

LLVM IR (-O2):
%struct.pass_session = type opaque
@.str = [2 x i8] c"@\00"
@.str.1 = [19 x i8] c"passwords: fts=%lx\00"
define %struct.pass_session* @pass_get_password(%struct.pass_session* %0, i8* %1, i8* %2) {
%4 = icmp eq %struct.pass_session* %0, null
br i1 %4, label %25, label %5
5: ; preds = %3
%6 = tail call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %1, i8* null)
%7 = bitcast %struct.pass_session* %0 to i8*
%8 = tail call i8* @pass_find_session(i8* %7, i8* %6)
%9 = tail call i32 @av_free(i8* %6)
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %20
11: ; preds = %5
%12 = tail call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* null)
%13 = tail call i8* @pass_find_session(i8* %7, i8* %12)
%14 = tail call i32 @av_free(i8* %12)
%15 = icmp eq i8* %13, null
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = tail call i8* (i8*, i8*, i8*, i8*, ...) @av_stradd(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %1, i8* null)
%18 = tail call i8* @pass_find_session(i8* %7, i8* %17)
%19 = tail call i32 @av_free(i8* %17)
br label %20
20: ; preds = %5, %16, %11
%21 = phi i8* [ %18, %16 ], [ %13, %11 ], [ %8, %5 ]
%22 = bitcast i8* %21 to %struct.pass_session*
%23 = ptrtoint i8* %21 to i64
%24 = tail call i32 @av_log(i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %3, %20
%26 = phi %struct.pass_session* [ %22, %20 ], [ null, %3 ]
ret %struct.pass_session* %26
}