#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 more_calls(char);
int call_me(char *a) {
  char *orig_a = a;
  while (*a)
    ++a;
  if (more_calls(*orig_a))
    return (int)a - (int)orig_a;
  else
    return more_calls(*(orig_a + 1));
}


x86 assembly (clang, -O0):
<call_me>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1142 <call_me+0x32>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <call_me+0x14>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <more_calls@plt>
cmp    $0x0,%eax
je     1169 <call_me+0x59>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1179 <call_me+0x69>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <more_calls@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_me>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
cmpb   $0x0,(%r14,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1120 <call_me+0x10>
movsbl (%r14),%edi
call   1030 <more_calls@plt>
test   %eax,%eax
je     1145 <call_me+0x35>
add    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movsbl 0x1(%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <more_calls@plt>

LLVM IR (-O0):
define i32 @call_me(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
store i8* %5, i8** %4
br label %6
6: ; preds = %10, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %6
13: ; preds = %6
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i32 @more_calls(i8 signext %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = ptrtoint i8* %19 to i32
%21 = load i8*, i8** %4
%22 = ptrtoint i8* %21 to i32
%23 = sub nsw i32 %20, %22
store i32 %23, i32* %2
br label %29
24: ; preds = %13
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = call i32 @more_calls(i8 signext %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %24, %18
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @call_me(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = load i8, i8* %0
%9 = tail call i32 @more_calls(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %7
%12 = ptrtoint i8* %3 to i64
%13 = trunc i64 %12 to i32
%14 = ptrtoint i8* %0 to i64
%15 = trunc i64 %14 to i32
%16 = sub nsw i32 %13, %15
br label %21
17: ; preds = %7
%18 = getelementptr inbounds i8, i8* %0, i64 1
%19 = load i8, i8* %18
%20 = tail call i32 @more_calls(i8 signext %19)
br label %21
21: ; preds = %17, %11
%22 = phi i32 [ %16, %11 ], [ %20, %17 ]
ret i32 %22
}