#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*/ Camelback2HungaryX(char *, char **);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int test14() {
  char *camelback_test = "aaaBbCccDdd";
  char *anticipated_test = "aaa_bbCccDdd";
  printf("Input is %s\n", camelback_test);
  char *result = (char *)malloc(strlen(camelback_test) * 2);
  memset(result, 0, strlen(camelback_test) * 2);
  Camelback2HungaryX(camelback_test, &result);
  printf("result is %s \n", result);
  if (strcmp(anticipated_test, result) == 0) {
    free(result);
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<test14>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe81(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe82(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
shl    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
shl    $0x1,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <Camelback2HungaryX@plt>
mov    -0x20(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <test14+0xaf>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1226 <test14+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test14>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe9a(%rip),%rdi
lea    0xe7a(%rip),%rbx
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rax,1),%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rax,1),%edx
xor    %r14d,%r14d
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <Camelback2HungaryX@plt>
mov    0x8(%rsp),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xe24(%rip),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1202 <test14+0x92>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"aaaBbCccDdd\00"
@.str.1 = [13 x i8] c"aaa_bbCccDdd\00"
@.str.2 = [13 x i8] c"Input is %s\0A\00"
@.str.3 = [15 x i8] c"result is %s \0A\00"
define i32 @test14() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = mul nsw i32 %8, 2
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = mul nsw i32 %14, 2
%16 = call i32 @memset(i8* %12, i32 0, i32 %15)
%17 = load i8*, i8** %2
%18 = call i32 @Camelback2HungaryX(i8* %17, i8** %4)
%19 = load i8*, i8** %4
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %0
%26 = load i8*, i8** %4
%27 = call i32 @free(i8* %26)
store i32 1, i32* %1
br label %29
28: ; preds = %0
store i32 0, i32* %1
br label %29
29: ; preds = %28, %25
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [12 x i8] c"aaaBbCccDdd\00"
@.str.1 = [13 x i8] c"aaa_bbCccDdd\00"
@.str.2 = [13 x i8] c"Input is %s\0A\00"
@.str.3 = [15 x i8] c"result is %s \0A\00"
define i32 @test14() {
%1 = alloca i8*
%2 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i8** %1 to i8*
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = shl nsw i32 %4, 1
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %1
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = shl nsw i32 %8, 1
%10 = tail call i32 @memset(i8* %7, i32 0, i32 %9)
%11 = call i32 @Camelback2HungaryX(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1)
%12 = load i8*, i8** %1
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %1
%15 = call i64 @strcmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load i8*, i8** %1
%19 = call i32 @free(i8* %18)
br label %20
20: ; preds = %0, %17
%21 = phi i32 [ 1, %17 ], [ 0, %0 ]
ret i32 %21
}