#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*/ fputc(int, int /*<<< orphan*/ *);
void _fio_write_header(FILE *fp, char *fname) {
  char *sbuf;
  while (*fname)
    fputc(*fname++, fp);
  fputc(0x0D, fp);
  sbuf = "**TransWorks V1.2011.04";
  while (*sbuf)
    fputc(*sbuf++, fp);
  fputc(0x0D, fp);
  sbuf = "10";
  while (*sbuf)
    fputc(*sbuf++, fp);
  fputc(0x0D, fp);
}


x86 assembly (clang, -O0):
<_fio_write_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     114d <_fio_write_header+0x3d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
jmp    1120 <_fio_write_header+0x10>
mov    -0x8(%rbp),%rsi
mov    $0xd,%edi
call   1030 <fputc@plt>
lea    0xe9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1193 <_fio_write_header+0x83>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
jmp    1166 <_fio_write_header+0x56>
mov    -0x8(%rbp),%rsi
mov    $0xd,%edi
call   1030 <fputc@plt>
lea    0xe70(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d9 <_fio_write_header+0xc9>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
jmp    11ac <_fio_write_header+0x9c>
mov    -0x8(%rbp),%rsi
mov    $0xd,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fio_write_header>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rsi),%al
test   %al,%al
je     1146 <_fio_write_header+0x36>
mov    %rsi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <_fio_write_header+0x20>
mov    $0xd,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x2a,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x2a,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x54,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x72,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x61,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x6e,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x73,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x57,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x6f,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x72,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x6b,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x73,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x56,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x31,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x2e,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x32,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x30,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x31,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x31,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x2e,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x30,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x34,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0xd,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x31,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x30,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0xd,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"**TransWorks V1.2011.04\00"
@.str.1 = [3 x i8] c"10\00"
define void @_fio_write_header(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %10, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %4
%13 = load i8, i8* %11
%14 = sext i8 %13 to i32
%15 = load i32*, i32** %3
%16 = call i32 @fputc(i32 %14, i32* %15)
br label %6
17: ; preds = %6
%18 = load i32*, i32** %3
%19 = call i32 @fputc(i32 13, i32* %18)
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %5
br label %20
20: ; preds = %24, %17
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
%27 = load i8, i8* %25
%28 = sext i8 %27 to i32
%29 = load i32*, i32** %3
%30 = call i32 @fputc(i32 %28, i32* %29)
br label %20
31: ; preds = %20
%32 = load i32*, i32** %3
%33 = call i32 @fputc(i32 13, i32* %32)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %34
34: ; preds = %38, %31
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
%41 = load i8, i8* %39
%42 = sext i8 %41 to i32
%43 = load i32*, i32** %3
%44 = call i32 @fputc(i32 %42, i32* %43)
br label %34
45: ; preds = %34
%46 = load i32*, i32** %3
%47 = call i32 @fputc(i32 13, i32* %46)
ret void
}

LLVM IR (-O2):
define void @_fio_write_header(i32* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %11, %5 ], [ %3, %2 ]
%7 = phi i8* [ %8, %5 ], [ %1, %2 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = sext i8 %6 to i32
%10 = tail call i32 @fputc(i32 %9, i32* %0)
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %2
%14 = tail call i32 @fputc(i32 13, i32* %0)
%15 = tail call i32 @fputc(i32 42, i32* %0)
%16 = tail call i32 @fputc(i32 42, i32* %0)
%17 = tail call i32 @fputc(i32 84, i32* %0)
%18 = tail call i32 @fputc(i32 114, i32* %0)
%19 = tail call i32 @fputc(i32 97, i32* %0)
%20 = tail call i32 @fputc(i32 110, i32* %0)
%21 = tail call i32 @fputc(i32 115, i32* %0)
%22 = tail call i32 @fputc(i32 87, i32* %0)
%23 = tail call i32 @fputc(i32 111, i32* %0)
%24 = tail call i32 @fputc(i32 114, i32* %0)
%25 = tail call i32 @fputc(i32 107, i32* %0)
%26 = tail call i32 @fputc(i32 115, i32* %0)
%27 = tail call i32 @fputc(i32 32, i32* %0)
%28 = tail call i32 @fputc(i32 86, i32* %0)
%29 = tail call i32 @fputc(i32 49, i32* %0)
%30 = tail call i32 @fputc(i32 46, i32* %0)
%31 = tail call i32 @fputc(i32 50, i32* %0)
%32 = tail call i32 @fputc(i32 48, i32* %0)
%33 = tail call i32 @fputc(i32 49, i32* %0)
%34 = tail call i32 @fputc(i32 49, i32* %0)
%35 = tail call i32 @fputc(i32 46, i32* %0)
%36 = tail call i32 @fputc(i32 48, i32* %0)
%37 = tail call i32 @fputc(i32 52, i32* %0)
%38 = tail call i32 @fputc(i32 13, i32* %0)
%39 = tail call i32 @fputc(i32 49, i32* %0)
%40 = tail call i32 @fputc(i32 48, i32* %0)
%41 = tail call i32 @fputc(i32 13, i32* %0)
ret void
}