#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(char);
int strlen(char *);
char toupper(char);
char *strup(char *in) {
  char c;
  int i;
  for (i = 0; i < strlen(in); i++) {
    c = in[i];
    if (islower(c))
      c = toupper(c);
    in[i] = c;
  }
  return in;
}


x86 assembly (clang, -O0):
<strup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11a8 <strup+0x78>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     118c <strup+0x5c>
movsbl -0x9(%rbp),%edi
call   1040 <toupper@plt>
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <strup+0x13>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
test   %eax,%eax
jle    1189 <strup+0x59>
xor    %ebp,%ebp
jmp    1167 <strup+0x37>
nopw   0x0(%rax,%rax,1)
mov    %bl,(%r14,%rbp,1)
add    $0x1,%rbp
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1189 <strup+0x59>
movzbl (%r14,%rbp,1),%ebx
movsbl %bl,%r15d
mov    %r15d,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1150 <strup+0x20>
mov    %r15d,%edi
call   1040 <toupper@plt>
mov    %eax,%ebx
jmp    1150 <strup+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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