#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 */
scalar_t__ islower(unsigned char);
int /*<<< orphan*/ putchar(unsigned char);
int strlen(char *);
unsigned char toupper(unsigned char);
void toupper_arg1(char *arg) {
  int i;
  unsigned char c;
  if (arg == NULL) {
    return;
  }
  if (strlen(arg) > 0) {
    for (i = 0; i < strlen(arg); i++) {
      c = arg[i];
      if (islower(c)) {
        c = toupper(c);
      }
      putchar(c);
    }
  }
}


x86 assembly (clang, -O0):
<toupper_arg1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115c <toupper_arg1+0x1c>
jmp    11da <toupper_arg1+0x9a>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jle    11da <toupper_arg1+0x9a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11d5 <toupper_arg1+0x95>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     11be <toupper_arg1+0x7e>
movzbl -0xd(%rbp),%edi
call   1050 <toupper@plt>
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1175 <toupper_arg1+0x35>
jmp    11da <toupper_arg1+0x9a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toupper_arg1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11ad <toupper_arg1+0x6d>
mov    %rdi,%r14
call   1060 <strlen@plt>
test   %eax,%eax
jle    11ad <toupper_arg1+0x6d>
mov    %r14,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11ad <toupper_arg1+0x6d>
xor    %ebp,%ebp
jmp    118b <toupper_arg1+0x4b>
nopl   0x0(%rax,%rax,1)
movzbl %bl,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
mov    %r14,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11ad <toupper_arg1+0x6d>
movzbl (%r14,%rbp,1),%ebx
movzbl %bl,%r15d
mov    %r15d,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1170 <toupper_arg1+0x30>
mov    %r15d,%edi
call   1050 <toupper@plt>
mov    %eax,%ebx
jmp    1170 <toupper_arg1+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @toupper_arg1(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %24, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %6, %17
%10 = phi i64 [ %20, %17 ], [ 0, %6 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i64 @islower(i8 zeroext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = tail call zeroext i8 @toupper(i8 zeroext %12)
br label %17
17: ; preds = %15, %9
%18 = phi i8 [ %16, %15 ], [ %12, %9 ]
%19 = tail call i32 @putchar(i8 zeroext %18)
%20 = add nuw nsw i64 %10, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %9, label %24
24: ; preds = %17, %6, %3, %1
ret void
}