#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 /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ toupper(char);
int main() {
  int counter = 0;
  char stringupper[] = "hello, world\n";
  while (stringupper[counter]) {
    char mychar = stringupper[counter];
    putchar(toupper(mychar));
    counter++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x16(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xebb(%rip),%ax
mov    %ax,-0xa(%rbp)
movslq -0x8(%rbp),%rax
cmpb   $0x0,-0x16(%rbp,%rax,1)
je     118d <main+0x6d>
movslq -0x8(%rbp),%rax
mov    -0x16(%rbp,%rax,1),%al
mov    %al,-0x17(%rbp)
movsbl -0x17(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x68,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x65,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x6c,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x6c,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x2c,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x77,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x72,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x6c,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0x64,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.stringupper = [14 x i8] c"hello, world\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [14 x i8]
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
%5 = bitcast [14 x i8]* %3 to i8*
br label %6
6: ; preds = %12, %0
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %6
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %4
%17 = load i8, i8* %4
%18 = call i32 @toupper(i8 signext %17)
%19 = call i32 @putchar(i32 %18)
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %6
22: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @toupper(i8 signext 104)
%2 = tail call i32 @putchar(i32 %1)
%3 = tail call i32 @toupper(i8 signext 101)
%4 = tail call i32 @putchar(i32 %3)
%5 = tail call i32 @toupper(i8 signext 108)
%6 = tail call i32 @putchar(i32 %5)
%7 = tail call i32 @toupper(i8 signext 108)
%8 = tail call i32 @putchar(i32 %7)
%9 = tail call i32 @toupper(i8 signext 111)
%10 = tail call i32 @putchar(i32 %9)
%11 = tail call i32 @toupper(i8 signext 44)
%12 = tail call i32 @putchar(i32 %11)
%13 = tail call i32 @toupper(i8 signext 32)
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 @toupper(i8 signext 119)
%16 = tail call i32 @putchar(i32 %15)
%17 = tail call i32 @toupper(i8 signext 111)
%18 = tail call i32 @putchar(i32 %17)
%19 = tail call i32 @toupper(i8 signext 114)
%20 = tail call i32 @putchar(i32 %19)
%21 = tail call i32 @toupper(i8 signext 108)
%22 = tail call i32 @putchar(i32 %21)
%23 = tail call i32 @toupper(i8 signext 100)
%24 = tail call i32 @putchar(i32 %23)
%25 = tail call i32 @toupper(i8 signext 10)
%26 = tail call i32 @putchar(i32 %25)
ret i32 0
}