#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*/ encode(char *, int, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int do_encode(char *input, char *output, int len, char *infilename) {
  int mode, namelen;
  strcpy(output, "begin 640 ");
  strcat(output, infilename);
  strcat(output, " \n");
  {
    namelen = strlen(infilename);
    encode(input, len, output + strlen(output));
    return strlen(output);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<do_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
cltq
add    %rax,%rdx
call   1030 <encode@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_encode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdx
add    %rbx,%rdx
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <encode@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <strlen@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"begin 640 \00"
@.str.1 = [3 x i8] c" \0A\00"
define i32 @do_encode(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i8*, i8** %6
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %6
%14 = load i8*, i8** %8
%15 = call i32 @strcat(i8* %13, i8* %14)
%16 = load i8*, i8** %6
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %10
%20 = load i8*, i8** %5
%21 = load i32, i32* %7
%22 = load i8*, i8** %6
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = call i32 @encode(i8* %20, i32 %21, i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @strlen(i8* %28)
ret i32 %29
}

LLVM IR (-O2):
@.str = [11 x i8] c"begin 640 \00"
@.str.1 = [3 x i8] c" \0A\00"
define i32 @do_encode(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strcat(i8* %1, i8* %3)
%7 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @strlen(i8* %3)
%9 = tail call i32 @strlen(i8* %1)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = tail call i32 @encode(i8* %0, i32 %2, i8* %11)
%13 = tail call i32 @strlen(i8* %1)
ret i32 %13
}