#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 {
  int /*<<< orphan*/ pw_gid;
  int /*<<< orphan*/ pw_uid;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int S_IRGRP;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fchown(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *generate_rand_pw(int);
int open(char *, int, int);
void write_example_passwd(char *pwfile, char pwlocation, struct passwd *pw) {
  FILE *f;
  int i;
  if ((i = open(pwfile, O_CREAT | O_WRONLY | O_TRUNC,
                (S_IRUSR | S_IWUSR | (pwlocation == 0 ? (S_IRGRP) : 0)))) == -1)
    return;
  fchown(i, (pwlocation == 0 ? 0 : pw->pw_uid),
         (pwlocation == 0 ? 0 : pw->pw_gid));
  close(i);
  if (!(f = fopen(pwfile, "w")))
    return;
  fprintf(f, "# %s Password file for axspawn\n",
          (pwlocation == 0 ? "System" : "User"));
  if (pwlocation == 0) {
    fprintf(f, "# disable user self-administered passwords in $HOME/.%s\n",
            "bcpasswd");
    fprintf(f, "# with the line \"systempasswordonly\"\n");
    fprintf(f, "# systempasswordonly\n");
  }
  fprintf(f, "# Examples (sys and md5 passwords may differ):\n");
  fprintf(f, "# md5 standard (secure) - length: >= %d and <= %d characters\n",
          8, 80);
  fprintf(f, "# %smd5:%s\n", (pwlocation == 0 ? "username:" : ""),
          generate_rand_pw(8));
  fprintf(f,
          "# sys/baycom standard (not very secure) - length: >= %d and <= %d "
          "characters\n",
          20, 80);
  fprintf(f, "# %ssys:%s\n", (pwlocation == 0 ? "username:" : ""),
          generate_rand_pw(20));
  fprintf(f, "# unix standard (plaintext): no password is read here. Your "
             "password is looked\n");
  fprintf(f, "#   up during login in the system password table /etc/passwd or "
             "/etc/shadow\n");
  fprintf(f, "# unix\n");
  fclose(f);
}


x86 assembly (clang, -O0):
<write_example_passwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    0x2e12(%rip),%rcx
or     (%rcx),%eax
mov    0x2e49(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    0x2e1c(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x28(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    11df <write_example_passwd+0x6f>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    11e9 <write_example_passwd+0x79>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e9 <write_example_passwd+0x79>
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x3c(%rbp),%eax
or     %eax,%edx
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    120e <write_example_passwd+0x9e>
jmp    1422 <write_example_passwd+0x2b2>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    122b <write_example_passwd+0xbb>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    1235 <write_example_passwd+0xc5>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    1252 <write_example_passwd+0xe2>
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
jmp    125b <write_example_passwd+0xeb>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%esi
mov    -0x40(%rbp),%edi
mov    -0x4c(%rbp),%edx
call   1080 <fchown@plt>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
mov    -0x8(%rbp),%rdi
lea    0xd84(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1294 <write_example_passwd+0x124>
jmp    1422 <write_example_passwd+0x2b2>
mov    -0x20(%rbp),%rdi
movsbl -0x9(%rbp),%ecx
lea    0xd86(%rip),%rdx
lea    0xd78(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xd4a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    1309 <write_example_passwd+0x199>
mov    -0x20(%rbp),%rdi
lea    0xd57(%rip),%rsi
lea    0xd89(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x8,%edx
mov    $0x50,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
movsbl -0x9(%rbp),%edx
lea    0xd4b(%rip),%rax
lea    0xdd5(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    $0x8,%edi
call   1030 <generate_rand_pw@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xda6(%rip),%rsi
mov    $0x14,%edx
mov    $0x50,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
movsbl -0x9(%rbp),%edx
lea    0xce7(%rip),%rax
lea    0xd71(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    $0x14,%edi
call   1030 <generate_rand_pw@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_example_passwd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e6a(%rip),%rcx
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2e50(%rip),%rcx
or     (%rcx),%eax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x2e0e(%rip),%rcx
mov    0x2e1f(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
xor    %ecx,%ecx
test   %r15b,%r15b
jne    11cd <write_example_passwd+0x4d>
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     124b <write_example_passwd+0xcb>
mov    %eax,%ebp
test   %r15b,%r15b
je     11ee <write_example_passwd+0x6e>
mov    (%r14),%edx
mov    0x4(%r14),%esi
jmp    11f2 <write_example_passwd+0x72>
xor    %esi,%esi
xor    %edx,%edx
mov    %ebp,%edi
call   1080 <fchown@plt>
mov    %ebp,%edi
call   1050 <close@plt>
lea    0xdf9(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     124b <write_example_passwd+0xcb>
mov    %rax,%rbx
test   %r15b,%r15b
lea    0xe01(%rip),%rax
lea    0xe01(%rip),%rdx
cmove  %rax,%rdx
lea    0xdcf(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r15b,%r15b
je     1256 <write_example_passwd+0xd6>
lea    0xe4c(%rip),%rbp
jmp    12a7 <write_example_passwd+0x127>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd1(%rip),%rsi
lea    0xe03(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe08(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe7f(%rip),%rbp
lea    0xdfe(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
mov    $0x50,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   1030 <generate_rand_pw@plt>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x14,%edx
mov    $0x50,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x14,%edi
call   1030 <generate_rand_pw@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x4f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe82(%rip),%rdi
mov    $0x4c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xeb6(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
%struct.passwd = type { i32, i32 }
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [32 x i8] c"# %s Password file for axspawn\0A\00"
@.str.2 = [7 x i8] c"System\00"
@.str.3 = [5 x i8] c"User\00"
@.str.4 = [57 x i8] c"# disable user self-administered passwords in $HOME/.%s\0A\00"
@.str.5 = [9 x i8] c"bcpasswd\00"
@.str.6 = [38 x i8] c"# with the line \22systempasswordonly\22\0A\00"
@.str.7 = [22 x i8] c"# systempasswordonly\0A\00"
@.str.8 = [48 x i8] c"# Examples (sys and md5 passwords may differ):\0A\00"
@.str.9 = [62 x i8] c"# md5 standard (secure) - length: >= %d and <= %d characters\0A\00"
@.str.10 = [12 x i8] c"# %smd5:%s\0A\00"
@.str.11 = [10 x i8] c"username:\00"
@.str.12 = [1 x i8] zeroinitializer
@.str.13 = [78 x i8] c"# sys/baycom standard (not very secure) - length: >= %d and <= %d characters\0A\00"
@.str.14 = [12 x i8] c"# %ssys:%s\0A\00"
@.str.15 = [80 x i8] c"# unix standard (plaintext): no password is read here. Your password is looked\0A\00"
@.str.16 = [77 x i8] c"# up during login in the system password table /etc/passwd or /etc/shadow\0A\00"
@.str.17 = [8 x i8] c"# unix\0A\00"
define void @write_example_passwd(i8* %0, i8 signext %1, %struct.passwd* %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca %struct.passwd*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
store %struct.passwd* %2, %struct.passwd** %6
%9 = load i8*, i8** %4
%10 = load i32, i32* @O_CREAT
%11 = load i32, i32* @O_WRONLY
%12 = or i32 %10, %11
%13 = load i32, i32* @O_TRUNC
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IRUSR
%16 = load i32, i32* @S_IWUSR
%17 = or i32 %15, %16
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = load i32, i32* @S_IRGRP
br label %24
23: ; preds = %3
br label %24
24: ; preds = %23, %21
%25 = phi i32 [ %22, %21 ], [ 0, %23 ]
%26 = or i32 %17, %25
%27 = call i32 @open(i8* %9, i32 %14, i32 %26)
store i32 %27, i32* %8
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %24
br label %108
30: ; preds = %24
%31 = load i32, i32* %8
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
br label %40
36: ; preds = %30
%37 = load %struct.passwd*, %struct.passwd** %6
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i32 0, i32 1
%39 = load i32, i32* %38
br label %40
40: ; preds = %36, %35
%41 = phi i32 [ 0, %35 ], [ %39, %36 ]
%42 = load i8, i8* %5
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
br label %50
46: ; preds = %40
%47 = load %struct.passwd*, %struct.passwd** %6
%48 = getelementptr inbounds %struct.passwd, %struct.passwd* %47, i32 0, i32 0
%49 = load i32, i32* %48
br label %50
50: ; preds = %46, %45
%51 = phi i32 [ 0, %45 ], [ %49, %46 ]
%52 = call i32 @fchown(i32 %31, i32 %41, i32 %51)
%53 = load i32, i32* %8
%54 = call i32 @close(i32 %53)
%55 = load i8*, i8** %4
%56 = call i32* @fopen(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %56, i32** %7
%57 = icmp ne i32* %56, null
br i1 %57, label %59, label %58
58: ; preds = %50
br label %108
59: ; preds = %50
%60 = load i32*, i32** %7
%61 = load i8, i8* %5
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %65)
%67 = load i8, i8* %5
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %77
70: ; preds = %59
%71 = load i32*, i32** %7
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32*, i32** %7
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%75 = load i32*, i32** %7
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %70, %59
%78 = load i32*, i32** %7
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%80 = load i32*, i32** %7
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 8, i32 80)
%82 = load i32*, i32** %7
%83 = load i8, i8* %5
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 0
%86 = zext i1 %85 to i64
%87 = select i1 %85, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0)
%88 = call i8* @generate_rand_pw(i32 8)
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %87, i8* %88)
%90 = load i32*, i32** %7
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.13, i64 0, i64 0), i32 20, i32 80)
%92 = load i32*, i32** %7
%93 = load i8, i8* %5
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 0
%96 = zext i1 %95 to i64
%97 = select i1 %95, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0)
%98 = call i8* @generate_rand_pw(i32 20)
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %97, i8* %98)
%100 = load i32*, i32** %7
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.15, i64 0, i64 0))
%102 = load i32*, i32** %7
%103 = call i32 (i32*, i8*, ...) @fprintf(i32* %102, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.16, i64 0, i64 0))
%104 = load i32*, i32** %7
%105 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
%106 = load i32*, i32** %7
%107 = call i32 @fclose(i32* %106)
br label %108
108: ; preds = %77, %58, %29
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i32, i32 }
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [32 x i8] c"# %s Password file for axspawn\0A\00"
@.str.2 = [7 x i8] c"System\00"
@.str.3 = [5 x i8] c"User\00"
@.str.4 = [57 x i8] c"# disable user self-administered passwords in $HOME/.%s\0A\00"
@.str.5 = [9 x i8] c"bcpasswd\00"
@.str.6 = [38 x i8] c"# with the line \22systempasswordonly\22\0A\00"
@.str.7 = [22 x i8] c"# systempasswordonly\0A\00"
@.str.8 = [48 x i8] c"# Examples (sys and md5 passwords may differ):\0A\00"
@.str.9 = [62 x i8] c"# md5 standard (secure) - length: >= %d and <= %d characters\0A\00"
@.str.10 = [12 x i8] c"# %smd5:%s\0A\00"
@.str.11 = [10 x i8] c"username:\00"
@.str.12 = [1 x i8] zeroinitializer
@.str.13 = [78 x i8] c"# sys/baycom standard (not very secure) - length: >= %d and <= %d characters\0A\00"
@.str.14 = [12 x i8] c"# %ssys:%s\0A\00"
@.str.15 = [80 x i8] c"# unix standard (plaintext): no password is read here. Your password is looked\0A\00"
@.str.16 = [77 x i8] c"# up during login in the system password table /etc/passwd or /etc/shadow\0A\00"
@.str.17 = [8 x i8] c"# unix\0A\00"
define void @write_example_passwd(i8* nocapture %0, i8 signext %1, %struct.passwd* nocapture %2) {
%4 = load i32, i32* @O_CREAT
%5 = load i32, i32* @O_WRONLY
%6 = or i32 %5, %4
%7 = load i32, i32* @O_TRUNC
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IRUSR
%10 = load i32, i32* @S_IWUSR
%11 = or i32 %10, %9
%12 = icmp eq i8 %1, 0
%13 = load i32, i32* @S_IRGRP
%14 = select i1 %12, i32 %13, i32 0
%15 = or i32 %11, %14
%16 = tail call i32 @open(i8* %0, i32 %8, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %51, label %18
18: ; preds = %3
br i1 %12, label %24, label %19
19: ; preds = %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 0
%23 = load i32, i32* %22
br label %24
24: ; preds = %18, %19
%25 = phi i32 [ %21, %19 ], [ 0, %18 ]
%26 = phi i32 [ %23, %19 ], [ 0, %18 ]
%27 = tail call i32 @fchown(i32 %16, i32 %25, i32 %26)
%28 = tail call i32 @close(i32 %16)
%29 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %51, label %31
31: ; preds = %24
%32 = select i1 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br i1 %12, label %34, label %38
34: ; preds = %31
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i64 37, i64 1, i32* %29)
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i64 21, i64 1, i32* %29)
br label %38
38: ; preds = %34, %31
%39 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %34 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0), %31 ]
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i64 47, i64 1, i32* %29)
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 8, i32 80)
%42 = tail call i8* @generate_rand_pw(i32 8)
%43 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %39, i8* %42)
%44 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.13, i64 0, i64 0), i32 20, i32 80)
%45 = tail call i8* @generate_rand_pw(i32 20)
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %39, i8* %45)
%47 = tail call i64 @fwrite(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.15, i64 0, i64 0), i64 79, i64 1, i32* %29)
%48 = tail call i64 @fwrite(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.16, i64 0, i64 0), i64 76, i64 1, i32* %29)
%49 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i64 7, i64 1, i32* %29)
%50 = tail call i32 @fclose(i32* %29)
br label %51
51: ; preds = %24, %3, %38
ret void
}