#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_passwd;
  int pw_uid;
  int pw_gid;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, ...);
int putpwent(const struct passwd *p, FILE *f) {
  int status;
  status = fprintf(f, "%s:%s", p->pw_name, p->pw_passwd) == EOF;
  status |= fprintf(f, ":%d:%d:%s", p->pw_uid, p->pw_gid, p->pw_gecos) == EOF;
  status |= fprintf(f, ":%s:%s\n", p->pw_dir, p->pw_shell) == EOF;
  return status;
}


x86 assembly (clang, -O0):
<putpwent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%r8
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%rcx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e29(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putpwent>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdx
mov    0x8(%rdi),%rcx
lea    0xed4(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2eab(%rip),%r15
cmp    (%r15),%rax
sete   %bpl
mov    0x10(%rbx),%edx
mov    0x14(%rbx),%ecx
mov    0x18(%rbx),%r8
lea    0xeb1(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    (%r15),%rax
sete   %r12b
or     %bpl,%r12b
mov    0x20(%rbx),%rdx
mov    0x28(%rbx),%rcx
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    (%r15),%rax
sete   %al
or     %r12b,%al
movzbl %al,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [6 x i8] c"%s:%s\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c":%d:%d:%s\00"
@.str.2 = [8 x i8] c":%s:%s\0A\00"
define i32 @putpwent(%struct.passwd* %0, i32* %1) {
%3 = alloca %struct.passwd*
%4 = alloca i32*
%5 = alloca i32
store %struct.passwd* %0, %struct.passwd** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = load %struct.passwd*, %struct.passwd** %3
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %7, i32 0, i32 0
%9 = load i8*, i8** %8
%10 = load %struct.passwd*, %struct.passwd** %3
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i32 0, i32 1
%12 = load i8*, i8** %11
%13 = call i64 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
%16 = zext i1 %15 to i32
store i32 %16, i32* %5
%17 = load i32*, i32** %4
%18 = load %struct.passwd*, %struct.passwd** %3
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = load %struct.passwd*, %struct.passwd** %3
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = load %struct.passwd*, %struct.passwd** %3
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %24, i32 0, i32 4
%26 = load i8*, i8** %25
%27 = call i64 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %23, i8* %26)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
%30 = zext i1 %29 to i32
%31 = load i32, i32* %5
%32 = or i32 %31, %30
store i32 %32, i32* %5
%33 = load i32*, i32** %4
%34 = load %struct.passwd*, %struct.passwd** %3
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 5
%36 = load i8*, i8** %35
%37 = load %struct.passwd*, %struct.passwd** %3
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i32 0, i32 6
%39 = load i8*, i8** %38
%40 = call i64 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %39)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
%43 = zext i1 %42 to i32
%44 = load i32, i32* %5
%45 = or i32 %44, %43
store i32 %45, i32* %5
%46 = load i32, i32* %5
ret i32 %46
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [6 x i8] c"%s:%s\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c":%d:%d:%s\00"
@.str.2 = [8 x i8] c":%s:%s\0A\00"
define i32 @putpwent(%struct.passwd* nocapture %0, i32* nocapture %1) {
%3 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 0
%4 = load i8*, i8** %3
%5 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 1
%6 = load i8*, i8** %5
%7 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %6)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
%10 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 3
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 4
%15 = load i8*, i8** %14
%16 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13, i8* %15)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
%19 = or i1 %9, %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 5
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %0, i64 0, i32 6
%23 = load i8*, i8** %22
%24 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %23)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
%27 = or i1 %19, %26
%28 = zext i1 %27 to i32
ret i32 %28
}