#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*/ encode(char const *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char const *);
void call_encode(const char *s) {
  if (!*s) {
    printf("empty string\n");
    return;
  }
  char *t = (char *)malloc(strlen(s));
  encode(s, t);
  printf("%s\n", t);
  free(t);
}


x86 assembly (clang, -O0):
<call_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    117c <call_encode+0x2c>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11b8 <call_encode+0x68>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <encode@plt>
mov    -0x10(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_encode>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     118d <call_encode+0x3d>
mov    %rdi,%rbx
call   1060 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <encode@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
lea    0xe6c(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"empty string\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @call_encode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = call i32 @encode(i8* %14, i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
br label %21
21: ; preds = %9, %7
ret void
}

LLVM IR (-O2):
@str = [13 x i8] c"empty string\00"
define void @call_encode(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %13
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @encode(i8* %0, i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
%12 = tail call i32 @free(i8* %9)
br label %13
13: ; preds = %6, %4
ret void
}