#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*/ free(char *);
int /*<<< orphan*/ increment_key(char *);
int /*<<< orphan*/ map_filled(char *);
char *str_malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
size_t map_left(char *key) {
  size_t size = 0;
  char *tmp = str_malloc(strlen(key));
  strcpy(tmp, key);
  while (!map_filled(tmp)) {
    increment_key(tmp);
    ++size;
  }
  free(tmp);
  return size;
}


x86 assembly (clang, -O0):
<map_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <str_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <map_filled@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <map_left+0x53>
jmp    11cd <map_left+0x6d>
mov    -0x18(%rbp),%rdi
call   1080 <increment_key@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1195 <map_left+0x35>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_left>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <str_malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1070 <map_filled@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11a8 <map_left+0x48>
nop
mov    %r14,%rdi
call   1080 <increment_key@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1070 <map_filled@plt>
test   %eax,%eax
je     1190 <map_left+0x30>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @map_left(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* %3
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i8* @str_malloc(i32 %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = load i8*, i8** %2
%10 = call i32 @strcpy(i8* %8, i8* %9)
br label %11
11: ; preds = %16, %1
%12 = load i8*, i8** %4
%13 = call i32 @map_filled(i8* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i32 @increment_key(i8* %17)
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
br label %11
21: ; preds = %11
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
%24 = load i64, i64* %3
ret i64 %24
}

LLVM IR (-O2):
define i64 @map_left(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i8* @str_malloc(i32 %2)
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i32 @map_filled(i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1, %7
%8 = phi i64 [ %10, %7 ], [ 0, %1 ]
%9 = tail call i32 @increment_key(i8* %3)
%10 = add i64 %8, 1
%11 = tail call i32 @map_filled(i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %1
%14 = phi i64 [ 0, %1 ], [ %10, %7 ]
%15 = tail call i32 @free(i8* %3)
ret i64 %14
}