#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ write_users(int /*<<< orphan*/ *, int, int);
void write_group(const char *filename, int pos) {
  FILE *f;
  f = fopen(filename, "w");
  fprintf(f, "one:x:1:one");
  write_users(f, pos, 1);
  fprintf(f, "two:x:2:two");
  write_users(f, pos, 2);
  fprintf(f, "three:x:3");
  write_users(f, pos, 3);
  fclose(f);
}


x86 assembly (clang, -O0):
<write_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1040 <write_users@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x2,%edx
call   1040 <write_users@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x3,%edx
call   1040 <write_users@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_group>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <write_users@plt>
lea    0xe8b(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1040 <write_users@plt>
lea    0xe6f(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1040 <write_users@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [12 x i8] c"one:x:1:one\00"
@.str.2 = [12 x i8] c"two:x:2:two\00"
@.str.3 = [10 x i8] c"three:x:3\00"
define void @write_group(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32*, i32** %5
%11 = load i32, i32* %4
%12 = call i32 @write_users(i32* %10, i32 %11, i32 1)
%13 = load i32*, i32** %5
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32*, i32** %5
%16 = load i32, i32* %4
%17 = call i32 @write_users(i32* %15, i32 %16, i32 2)
%18 = load i32*, i32** %5
%19 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32*, i32** %5
%21 = load i32, i32* %4
%22 = call i32 @write_users(i32* %20, i32 %21, i32 3)
%23 = load i32*, i32** %5
%24 = call i32 @fclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [12 x i8] c"one:x:1:one\00"
@.str.2 = [12 x i8] c"two:x:2:two\00"
@.str.3 = [10 x i8] c"three:x:3\00"
define void @write_group(i8* nocapture %0, i32 %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 11, i64 1, i32* %3)
%5 = tail call i32 @write_users(i32* %3, i32 %1, i32 1)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 11, i64 1, i32* %3)
%7 = tail call i32 @write_users(i32* %3, i32 %1, i32 2)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 9, i64 1, i32* %3)
%9 = tail call i32 @write_users(i32* %3, i32 %1, i32 3)
%10 = tail call i32 @fclose(i32* %3)
ret void
}