#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 */
unsigned int strlen(char *);
char toupper(char);
void load_input(char *argv[], char *input) {
  unsigned int a = 0;
  while (a < strlen(argv[1])) {
    input[a] = toupper(argv[1][a]);
    a++;
  }
  input[a] = '\0';
}


x86 assembly (clang, -O0):
<load_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jae    1185 <load_input+0x65>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <load_input+0x17>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_input>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x8(%rdi),%rdi
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1165 <load_input+0x45>
nopw   0x0(%rax,%rax,1)
mov    0x8(%r15),%rax
movsbl (%rax,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    0x8(%r15),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1140 <load_input+0x20>
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @load_input(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %13, %2
%7 = load i32, i32* %5
%8 = load i8**, i8*** %3
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strlen(i8* %10)
%12 = icmp ult i32 %7, %11
br i1 %12, label %13, label %28
13: ; preds = %6
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* %5
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = call signext i8 @toupper(i8 signext %20)
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i32, i32* %5
%27 = add i32 %26, 1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
%29 = load i8*, i8** %4
%30 = load i32, i32* %5
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
define void @load_input(i8** nocapture %0, i8* nocapture writeonly %1) {
%3 = getelementptr inbounds i8*, i8** %0, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @strlen(i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %14, %7 ], [ 0, %2 ]
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 %8
%11 = load i8, i8* %10
%12 = tail call signext i8 @toupper(i8 signext %11)
%13 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 %12, i8* %13
%14 = add nuw nsw i64 %8, 1
%15 = load i8*, i8** %3
%16 = tail call i32 @strlen(i8* %15)
%17 = zext i32 %16 to i64
%18 = icmp ult i64 %14, %17
br i1 %18, label %7, label %19
19: ; preds = %7
%20 = and i64 %14, 4294967295
br label %21
21: ; preds = %19, %2
%22 = phi i64 [ 0, %2 ], [ %20, %19 ]
%23 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 0, i8* %23
ret void
}