#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_dir;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ read_formats(char *, int *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
void read_global_formats(int *numformatsp) {
  struct passwd *pwd;
  char filename[257 + 12];
  if ((pwd = getpwuid(getuid())) < 0) {
    fprintf(stderr, ">E Can't find home directory\n");
    exit(1);
  }
  sprintf(filename, "%s/sumlines.fmt", pwd->pw_dir);
  read_formats(filename, numformatsp, 0);
}


x86 assembly (clang, -O0):
<read_global_formats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jae    11aa <read_global_formats+0x4a>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5f(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1060 <read_formats@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_global_formats>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    (%rax),%rdx
lea    0xe9b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <read_formats@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@stderr = global i32 0
@.str = [30 x i8] c">E Can't find home directory\0A\00"
@.str.1 = [16 x i8] c"%s/sumlines.fmt\00"
define void @read_global_formats(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.passwd*
%4 = alloca [269 x i8]
store i32* %0, i32** %2
%5 = call i32 (...) @getuid()
%6 = call %struct.passwd* @getpwuid(i32 %5)
store %struct.passwd* %6, %struct.passwd** %3
%7 = icmp ult %struct.passwd* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = getelementptr inbounds [269 x i8], [269 x i8]* %4, i64 0, i64 0
%14 = load %struct.passwd*, %struct.passwd** %3
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [269 x i8], [269 x i8]* %4, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @read_formats(i8* %18, i32* %19, i32 0)
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s/sumlines.fmt\00"
define void @read_global_formats(i32* %0) {
%2 = alloca [269 x i8]
%3 = getelementptr inbounds [269 x i8], [269 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @getuid()
%5 = tail call %struct.passwd* @getpwuid(i32 %4)
%6 = getelementptr inbounds %struct.passwd, %struct.passwd* %5, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @read_formats(i8* %3, i32* %0, i32 0)
ret void
}