#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 EXIT_SUCCESS;
int /*<<< orphan*/ assert(int);
char *malloc(int);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ to_upper_a(char *);
int /*<<< orphan*/ to_upper_b(char *);
int main(void) {
  char *a = malloc(4 * sizeof(char));
  strcpy(a, "asd");
  assert(strcmp(to_upper_a(a), "ASD") == 0);
  strcpy(a, "asd");
  assert(strcmp(to_upper_b(a), "ASD") == 0);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1080 <to_upper_a@plt>
mov    %eax,%edi
lea    0xe65(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <to_upper_b@plt>
mov    %eax,%edi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe87(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <to_upper_a@plt>
lea    0xe71(%rip),%r15
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <to_upper_b@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"ASD\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @malloc(i32 4)
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 @to_upper_a(i8* %6)
%8 = call i64 @strcmp(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %2
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %2
%15 = call i32 @to_upper_b(i8* %14)
%16 = call i64 @strcmp(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}

LLVM IR (-O2):
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"ASD\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%2 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @to_upper_a(i8* %1)
%4 = tail call i64 @strcmp(i32 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @to_upper_b(i8* %1)
%10 = tail call i64 @strcmp(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}