#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 */
char *chaz_Util_strdup(char const *);
char toupper(unsigned char);
char *chaz_ConfWriterC_uppercase_string(const char *src) {
  char *retval = chaz_Util_strdup(src);
  size_t i;
  for (i = 0; retval[i]; ++i) {
    retval[i] = toupper((unsigned char)retval[i]);
  }
  return retval;
}


x86 assembly (clang, -O0):
<chaz_ConfWriterC_uppercase_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <chaz_Util_strdup@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1182 <chaz_ConfWriterC_uppercase_string+0x62>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <chaz_ConfWriterC_uppercase_string+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_ConfWriterC_uppercase_string>:
push   %r14
push   %rbx
push   %rax
call   1040 <chaz_Util_strdup@plt>
mov    %rax,%r14
mov    (%rax),%al
test   %al,%al
je     1156 <chaz_ConfWriterC_uppercase_string+0x36>
mov    %r14,%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <chaz_ConfWriterC_uppercase_string+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @chaz_ConfWriterC_uppercase_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @chaz_Util_strdup(i8* %5)
store i8* %6, i8** %3
store i64 0, i64* %4
br label %7
7: ; preds = %22, %1
%8 = load i8*, i8** %3
%9 = load i64, i64* %4
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = load i64, i64* %4
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i8, i8* %16
%18 = call signext i8 @toupper(i8 zeroext %17)
%19 = load i8*, i8** %3
%20 = load i64, i64* %4
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %13
%23 = load i64, i64* %4
%24 = add i64 %23, 1
store i64 %24, i64* %4
br label %7
25: ; preds = %7
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
define i8* @chaz_ConfWriterC_uppercase_string(i8* %0) {
%2 = tail call i8* @chaz_Util_strdup(i8* %0)
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %12, %5 ], [ %3, %1 ]
%7 = phi i8* [ %11, %5 ], [ %2, %1 ]
%8 = phi i64 [ %10, %5 ], [ 0, %1 ]
%9 = tail call signext i8 @toupper(i8 zeroext %6)
store i8 %9, i8* %7
%10 = add i64 %8, 1
%11 = getelementptr inbounds i8, i8* %2, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %1
ret i8* %2
}