#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 */
struct passwd {
  char *pw_name;
  char *pw_shell;
  char *pw_dir;
};

/* Variables and functions */
struct passwd *internal_getpwuid(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  struct passwd *pw1;
  pw1 = internal_getpwuid("passwdparsertester.test", 100);
  if (pw1) {
    printf("found user %s with shell %s and home %s\n", pw1->pw_name,
           pw1->pw_shell, pw1->pw_dir);
  } else {
    printf("found nothing\n");
  }
  return 0;
}


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)
lea    0xec3(%rip),%rdi
mov    $0x64,%esi
call   1040 <internal_getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1180 <main+0x60>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118e <main+0x6e>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x64,%esi
call   1050 <internal_getpwuid@plt>
test   %rax,%rax
je     1162 <main+0x32>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%rcx
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116e <main+0x3e>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i8* }
@.str = [24 x i8] c"passwdparsertester.test\00"
@.str.1 = [41 x i8] c"found user %s with shell %s and home %s\0A\00"
@.str.2 = [15 x i8] c"found nothing\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.passwd* @internal_getpwuid(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 100)
store %struct.passwd* %7, %struct.passwd** %6
%8 = load %struct.passwd*, %struct.passwd** %6
%9 = icmp ne %struct.passwd* %8, null
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load %struct.passwd*, %struct.passwd** %6
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = load %struct.passwd*, %struct.passwd** %6
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i32 0, i32 1
%16 = load i8*, i8** %15
%17 = load %struct.passwd*, %struct.passwd** %6
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 2
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %16, i8* %19)
br label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %10
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8* }
@.str = [24 x i8] c"passwdparsertester.test\00"
@.str.1 = [41 x i8] c"found user %s with shell %s and home %s\0A\00"
@str = [14 x i8] c"found nothing\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.passwd* @internal_getpwuid(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 100)
%4 = icmp eq %struct.passwd* %3, null
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = getelementptr inbounds %struct.passwd, %struct.passwd* %3, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %3, i64 0, i32 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds %struct.passwd, %struct.passwd* %3, i64 0, i32 2
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %9, i8* %11)
br label %15
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %5
ret i32 0
}