#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 */
char *tl_getc(const char *str) {
  static char *c;
  static char *mmbr;
  if (str != mmbr) {
    c = (char *)str;
    mmbr = (char *)str;
  }
  if (*c == '\0') {
    mmbr = NULL;
    return c;
  }
  return c++;
}


x86 assembly (clang, -O0):
<tl_getc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    0x2f1d(%rip),%rax
je     112f <tl_getc+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,0x2f04(%rip)
mov    -0x10(%rbp),%rax
mov    %rax,0x2f01(%rip)
mov    0x2ef2(%rip),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115d <tl_getc+0x5d>
movq   $0x0,0x2ee3(%rip)
mov    0x2ed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1176 <tl_getc+0x76>
mov    0x2ec4(%rip),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x2eb6(%rip)
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tl_getc>:
cmp    %rdi,0x2f29(%rip)
je     112b <tl_getc+0x2b>
mov    %rdi,%rax
mov    %rdi,0x2f15(%rip)
mov    %rdi,0x2f16(%rip)
cmpb   $0x0,(%rax)
je     1137 <tl_getc+0x37>
lea    0x1(%rax),%rcx
mov    %rcx,0x2efe(%rip)
ret
mov    0x2ef6(%rip),%rax
cmpb   $0x0,(%rax)
jne    111f <tl_getc+0x1f>
movq   $0x0,0x2eee(%rip)
ret

LLVM IR (-O0):
@tl_getc.c = internal global i8* null
@tl_getc.mmbr = internal global i8* null
define i8* @tl_getc(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8*, i8** @tl_getc.mmbr
%6 = icmp ne i8* %4, %5
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8*, i8** %3
store i8* %8, i8** @tl_getc.c
%9 = load i8*, i8** %3
store i8* %9, i8** @tl_getc.mmbr
br label %10
10: ; preds = %7, %1
%11 = load i8*, i8** @tl_getc.c
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
store i8* null, i8** @tl_getc.mmbr
%16 = load i8*, i8** @tl_getc.c
store i8* %16, i8** %2
br label %20
17: ; preds = %10
%18 = load i8*, i8** @tl_getc.c
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** @tl_getc.c
store i8* %18, i8** %2
br label %20
20: ; preds = %17, %15
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@tl_getc.c = internal unnamed_addr global i8* null
@tl_getc.mmbr = internal unnamed_addr global i8* null
define i8* @tl_getc(i8* %0) {
%2 = load i8*, i8** @tl_getc.mmbr
%3 = icmp eq i8* %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load i8*, i8** @tl_getc.c
br label %7
6: ; preds = %1
store i8* %0, i8** @tl_getc.c
store i8* %0, i8** @tl_getc.mmbr
br label %7
7: ; preds = %4, %6
%8 = phi i8* [ %5, %4 ], [ %0, %6 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i8* null, i8** @tl_getc.mmbr
br label %14
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %13, i8** @tl_getc.c
br label %14
14: ; preds = %12, %11
ret i8* %8
}