#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*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int Camelback2PascalX(const char *src, char **dst) {
  if (src == NULL || dst == NULL) {
    printf("src == NULL || dst == NULL\n");
    return -1;
  }
  int length = strlen(src);
  char *dstx = *dst;
  strcpy(dstx, src);
  dstx[0] = src[0] - 32;
  return 0;
}


x86 assembly (clang, -O0):
<Camelback2PascalX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <Camelback2PascalX+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    116e <Camelback2PascalX+0x3e>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <Camelback2PascalX+0x7b>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x20,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Camelback2PascalX>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1162 <Camelback2PascalX+0x32>
mov    %rsi,%r14
test   %rsi,%rsi
je     1162 <Camelback2PascalX+0x32>
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    (%r14),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%al
add    $0xe0,%al
mov    %al,(%r14)
xor    %eax,%eax
jmp    1173 <Camelback2PascalX+0x43>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"src == NULL || dst == NULL\0A\00"
define i32 @Camelback2PascalX(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = icmp eq i8** %11, null
br i1 %12, label %13, label %15
13: ; preds = %10, %2
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %31
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %6
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = load i8*, i8** %4
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 32
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 %28, i8* %30
store i32 0, i32* %3
br label %31
31: ; preds = %15, %13
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@str = [27 x i8] c"src == NULL || dst == NULL\00"
define i32 @Camelback2PascalX(i8* %0, i8** %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8** %1, null
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %14
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %0)
%10 = load i8*, i8** %1
%11 = tail call i32 @strcpy(i8* %10, i8* %0)
%12 = load i8, i8* %0
%13 = add i8 %12, -32
store i8 %13, i8* %10
br label %14
14: ; preds = %8, %6
%15 = phi i32 [ -1, %6 ], [ 0, %8 ]
ret i32 %15
}