#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 */

/* Variables and functions */
int getenvironment(int *);
int getuserid(char *, int *);
char toupper(unsigned char);
int initializeprogram(char *puserid1, int *pusertype1, int *pweekends1) {
  int m, n, loop;
  char tempuser[4];
  int tempusertype, tempweekends;
  m = getenvironment(&tempweekends);
  n = getuserid(&tempuser[0], &tempusertype);
  for (loop = 0; loop < 4; loop++) {
    *puserid1 = toupper((unsigned char)tempuser[loop]);
    puserid1 = puserid1 + 1;
  }
  *pusertype1 = tempusertype;
  *pweekends1 = tempweekends;
  return n;
}


x86 assembly (clang, -O0):
<initializeprogram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <getenvironment@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <getuserid@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11a1 <initializeprogram+0x71>
movslq -0x24(%rbp),%rax
movzbl -0x28(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <initializeprogram+0x37>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initializeprogram>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
call   1050 <getenvironment@plt>
lea    0xc(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1040 <getuserid@plt>
mov    %eax,%ebp
movzbl 0xc(%rsp),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx)
movzbl 0xd(%rsp),%edi
call   1030 <toupper@plt>
mov    %al,0x1(%rbx)
movzbl 0xe(%rsp),%edi
call   1030 <toupper@plt>
mov    %al,0x2(%rbx)
movzbl 0xf(%rsp),%edi
call   1030 <toupper@plt>
mov    %al,0x3(%rbx)
mov    0x14(%rsp),%eax
mov    %eax,(%r15)
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @initializeprogram(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [4 x i8]
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%13 = call i32 @getenvironment(i32* %12)
store i32 %13, i32* %7
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%15 = call i32 @getuserid(i8* %14, i32* %11)
store i32 %15, i32* %8
store i32 0, i32* %9
br label %16
16: ; preds = %28, %3
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call signext i8 @toupper(i8 zeroext %23)
%25 = load i8*, i8** %4
store i8 %24, i8* %25
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %4
br label %28
28: ; preds = %19
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %16
31: ; preds = %16
%32 = load i32, i32* %11
%33 = load i32*, i32** %5
store i32 %32, i32* %33
%34 = load i32, i32* %12
%35 = load i32*, i32** %6
store i32 %34, i32* %35
%36 = load i32, i32* %8
ret i32 %36
}

LLVM IR (-O2):
define i32 @initializeprogram(i8* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [4 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = call i32 @getenvironment(i32* %6)
%11 = call i32 @getuserid(i8* %7, i32* %5)
%12 = load i8, i8* %7
%13 = call signext i8 @toupper(i8 zeroext %12)
store i8 %13, i8* %0
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%16 = load i8, i8* %15
%17 = call signext i8 @toupper(i8 zeroext %16)
store i8 %17, i8* %14
%18 = getelementptr inbounds i8, i8* %0, i64 2
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%20 = load i8, i8* %19
%21 = call signext i8 @toupper(i8 zeroext %20)
store i8 %21, i8* %18
%22 = getelementptr inbounds i8, i8* %0, i64 3
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%24 = load i8, i8* %23
%25 = call signext i8 @toupper(i8 zeroext %24)
store i8 %25, i8* %22
%26 = load i32, i32* %5
store i32 %26, i32* %1
%27 = load i32, i32* %6
store i32 %27, i32* %2
ret i32 %11
}