#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 newlabel();
int /*<<< orphan*/ output(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
void loadstring(char *s) {
  int m = newlabel();
  output("L%d .const ", m);
  for (; *s; ++s) {
    printf("%d,", (unsigned char)*s);
  }
  printf("0");
  output("; cta @L%d; atx A1; cta L%d;", m, m);
}


x86 assembly (clang, -O0):
<loadstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <newlabel@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <output@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     118a <loadstring+0x5a>
mov    -0x8(%rbp),%rax
movzbl (%rax),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1157 <loadstring+0x27>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <output@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadstring>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <newlabel@plt>
mov    %eax,%r14d
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <output@plt>
mov    (%rbx),%al
test   %al,%al
je     1198 <loadstring+0x58>
add    $0x1,%rbx
lea    0xe9a(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl %al,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <loadstring+0x40>
mov    $0x30,%edi
call   1030 <putchar@plt>
lea    0xe67(%rip),%rdi
mov    %r14d,%esi
mov    %r14d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <output@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"L%d .const \00"
@.str.1 = [4 x i8] c"%d,\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [29 x i8] c"; cta @L%d; atx A1; cta L%d;\00"
define void @loadstring(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @newlabel()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = call i32 (i8*, i32, ...) @output(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %16, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
br label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i8*, i32, ...) @output(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"L%d .const \00"
@.str.1 = [4 x i8] c"%d,\00"
@.str.3 = [29 x i8] c"; cta @L%d; atx A1; cta L%d;\00"
define void @loadstring(i8* nocapture %0) {
%2 = tail call i32 (...) @newlabel()
%3 = tail call i32 (i8*, i32, ...) @output(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %12, %6 ], [ %4, %1 ]
%8 = phi i8* [ %11, %6 ], [ %0, %1 ]
%9 = zext i8 %7 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %1
%15 = tail call i32 @putchar(i32 48)
%16 = tail call i32 (i8*, i32, ...) @output(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %2, i32 %2)
ret void
}