#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int strlen(char *);
void push_string(FILE *f, char *string) {
  fprintf(f, "\"\\x50\" //push eax\n");
  int left = strlen(string);
  if (left % 2 > 0) {
    fprintf(f, "\"\\xb0\\x%x\" //movb al, '%c'\n", string[left - 1],
            string[left - 1]);
    fprintf(f, "\"\\x66\\x50\" //pushw ax\n \"\\x31\\xc0\" //xor eax, eax\n");
    left = left - 1;
  }
  while (left / 4 > 0) {
    fprintf(f, "\"\\x68\\x%x\\x%x\\x%x\\x%x\" //push '%c%c%c%c'\n",
            string[left - 4], string[left - 3], string[left - 2],
            string[left - 1], string[left - 4], string[left - 3],
            string[left - 2], string[left - 1]);
    left = left - 4;
  }
  if (left / 2 > 0) {
    fprintf(f, "\"\\x66\\x68\\x%x\\x%x\" //pushw '%c%c'\n", string[left - 2],
            string[left - 1], string[left - 2], string[left - 1]);
    left = left - 2;
  }
}


x86 assembly (clang, -O0):
<push_string>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    11b2 <push_string+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <push_string+0x97>
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    1288 <push_string+0x168>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x2,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r8d
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r9d
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x4,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%ebx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x3,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r11d
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x2,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r10d
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%eax
lea    0xdff(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <push_string+0x97>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    12fd <push_string+0x1dd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x2,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r8d
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movsbl (%rax,%rsi,1),%r9d
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<push_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
and    $0x80000001,%eax
cmp    $0x1,%eax
jne    11a8 <push_string+0x78>
add    $0xffffffff,%r14d
movsbl 0x0(%r13,%r14,1),%ecx
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe99(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,0x8(%rsp)
cmp    $0x4,%r14d
mov    %r13,0x10(%rsp)
jl     126d <push_string+0x13d>
lea    -0x4(%r14),%eax
mov    %rax,0x20(%rsp)
lea    -0x3(%r14),%eax
mov    %rax,0x18(%rsp)
lea    -0x2(%r14),%r12d
lea    -0x1(%r14),%r15d
mov    0x8(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
lea    -0x4(%r14),%ebx
mov    0x20(%rsp),%rax
movsbl 0x0(%r13,%rax,1),%edx
mov    0x18(%rsp),%rax
movsbl 0x0(%r13,%rax,1),%ecx
movsbl 0x0(%r13,%r12,1),%r8d
movsbl 0x0(%r13,%r15,1),%r9d
mov    %rbp,%rdi
lea    0xe51(%rip),%rsi
xor    %eax,%eax
push   %r9
push   %r8
push   %rcx
push   %rdx
call   1040 <fprintf@plt>
add    $0x20,%rsp
add    $0xfffffffffffffffc,%r13
cmp    $0x7,%r14d
mov    %ebx,%r14d
ja     11e0 <push_string+0xb0>
cmp    $0x2,%ebx
jl     1275 <push_string+0x145>
lea    -0x2(%rbx),%eax
mov    0x10(%rsp),%rcx
movsbl (%rcx,%rax,1),%edx
add    $0xffffffff,%ebx
movsbl (%rcx,%rbx,1),%ecx
lea    0xe3e(%rip),%rsi
mov    0x8(%rsp),%rdi
mov    %edx,%r8d
mov    %ecx,%r9d
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
mov    %r14d,%ebx
cmp    $0x2,%ebx
jge    1233 <push_string+0x103>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\22\\x50\22 //push eax\0A\00"
@.str.1 = [28 x i8] c"\22\\xb0\\x%x\22 //movb al, '%c'\0A\00"
@.str.2 = [50 x i8] c"\22\\x66\\x50\22 //pushw ax\0A \22\\x31\\xc0\22 //xor eax, eax\0A\00"
@.str.3 = [42 x i8] c"\22\\x68\\x%x\\x%x\\x%x\\x%x\22 //push '%c%c%c%c'\0A\00"
@.str.4 = [35 x i8] c"\22\\x66\\x68\\x%x\\x%x\22 //pushw '%c%c'\0A\00"
define void @push_string(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i32*, i32** %3
%7 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = srem i32 %10, 2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %28)
%30 = load i32*, i32** %3
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %5
br label %34
34: ; preds = %13, %2
br label %35
35: ; preds = %39, %34
%36 = load i32, i32* %5
%37 = sdiv i32 %36, 4
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %100
39: ; preds = %35
%40 = load i32*, i32** %3
%41 = load i8*, i8** %4
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = load i8*, i8** %4
%49 = load i32, i32* %5
%50 = sub nsw i32 %49, 3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = load i8*, i8** %4
%56 = load i32, i32* %5
%57 = sub nsw i32 %56, 2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = load i8*, i8** %4
%63 = load i32, i32* %5
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = load i8*, i8** %4
%70 = load i32, i32* %5
%71 = sub nsw i32 %70, 4
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %69, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = load i8*, i8** %4
%77 = load i32, i32* %5
%78 = sub nsw i32 %77, 3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %76, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = load i8*, i8** %4
%84 = load i32, i32* %5
%85 = sub nsw i32 %84, 2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %83, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = load i8*, i8** %4
%91 = load i32, i32* %5
%92 = sub nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %90, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 %54, i32 %61, i32 %68, i32 %75, i32 %82, i32 %89, i32 %96)
%98 = load i32, i32* %5
%99 = sub nsw i32 %98, 4
store i32 %99, i32* %5
br label %35
100: ; preds = %35
%101 = load i32, i32* %5
%102 = sdiv i32 %101, 2
%103 = icmp sgt i32 %102, 0
br i1 %103, label %104, label %137
104: ; preds = %100
%105 = load i32*, i32** %3
%106 = load i8*, i8** %4
%107 = load i32, i32* %5
%108 = sub nsw i32 %107, 2
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %106, i64 %109
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = load i8*, i8** %4
%114 = load i32, i32* %5
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %113, i64 %116
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = load i8*, i8** %4
%121 = load i32, i32* %5
%122 = sub nsw i32 %121, 2
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %120, i64 %123
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = load i8*, i8** %4
%128 = load i32, i32* %5
%129 = sub nsw i32 %128, 1
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i8, i8* %127, i64 %130
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %112, i32 %119, i32 %126, i32 %133)
%135 = load i32, i32* %5
%136 = sub nsw i32 %135, 2
store i32 %136, i32* %5
br label %137
137: ; preds = %104, %100
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"\22\\x50\22 //push eax\0A\00"
@.str.1 = [28 x i8] c"\22\\xb0\\x%x\22 //movb al, '%c'\0A\00"
@.str.2 = [50 x i8] c"\22\\x66\\x50\22 //pushw ax\0A \22\\x31\\xc0\22 //xor eax, eax\0A\00"
@.str.3 = [42 x i8] c"\22\\x68\\x%x\\x%x\\x%x\\x%x\22 //push '%c%c%c%c'\0A\00"
@.str.4 = [35 x i8] c"\22\\x66\\x68\\x%x\\x%x\22 //pushw '%c%c'\0A\00"
define void @push_string(i32* nocapture %0, i8* %1) {
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 18, i64 1, i32* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = and i32 %4, -2147483647
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = add nsw i32 %4, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %12)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i64 49, i64 1, i32* %0)
br label %15
15: ; preds = %7, %2
%16 = phi i32 [ %8, %7 ], [ %4, %2 ]
%17 = icmp sgt i32 %16, 3
br i1 %17, label %18, label %42
18: ; preds = %15, %18
%19 = phi i32 [ %20, %18 ], [ %16, %15 ]
%20 = add nsw i32 %19, -4
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = add nsw i32 %19, -3
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = add nsw i32 %19, -2
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %1, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = add nsw i32 %19, -1
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %1, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %29, i32 %34, i32 %39, i32 %24, i32 %29, i32 %34, i32 %39)
%41 = icmp ugt i32 %19, 7
br i1 %41, label %18, label %42
42: ; preds = %18, %15
%43 = phi i32 [ %16, %15 ], [ %20, %18 ]
%44 = icmp sgt i32 %43, 1
br i1 %44, label %45, label %57
45: ; preds = %42
%46 = add nsw i32 %43, -2
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %1, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = add nsw i32 %43, -1
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %1, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %50, i32 %55, i32 %50, i32 %55)
br label %57
57: ; preds = %45, %42
ret void
}