#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*/ *);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int strlen(char const *);
int sio_write_cas_header(FILE *fp, const char *description) {
  if (!fp)
    return -1;
  rewind(fp);
  fputs("FUJI", fp);
  fputc(strlen(description) & 0xff, fp);
  fputc((strlen(description) >> 8) & 0xff, fp);
  fputc(0, fp);
  fputc(0, fp);
  fputs(description, fp);
  fputs("baud", fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x58, fp);
  fputc(0x02, fp);
  return 0;
}


x86 assembly (clang, -O0):
<sio_write_cas_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1167 <sio_write_cas_header+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <sio_write_cas_header+0xe3>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1060 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
sar    $0x8,%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1060 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1060 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1060 <fputc@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1060 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1060 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0x58,%edi
call   1060 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0x2,%edi
call   1060 <fputc@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sio_write_cas_header>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1211 <sio_write_cas_header+0xc1>
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <rewind@plt>
lea    0xe91(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
movzbl %al,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
movzbl %ah,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
xor    %ebp,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xe36(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    $0x58,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    1216 <sio_write_cas_header+0xc6>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"FUJI\00"
@.str.1 = [5 x i8] c"baud\00"
define i32 @sio_write_cas_header(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 -1, i32* %3
br label %42
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = call i32 @rewind(i32* %10)
%12 = load i32*, i32** %4
%13 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = and i32 %15, 255
%17 = load i32*, i32** %4
%18 = call i32 @fputc(i32 %16, i32* %17)
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = ashr i32 %20, 8
%22 = and i32 %21, 255
%23 = load i32*, i32** %4
%24 = call i32 @fputc(i32 %22, i32* %23)
%25 = load i32*, i32** %4
%26 = call i32 @fputc(i32 0, i32* %25)
%27 = load i32*, i32** %4
%28 = call i32 @fputc(i32 0, i32* %27)
%29 = load i8*, i8** %5
%30 = load i32*, i32** %4
%31 = call i32 @fputs(i8* %29, i32* %30)
%32 = load i32*, i32** %4
%33 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %32)
%34 = load i32*, i32** %4
%35 = call i32 @fputc(i32 0, i32* %34)
%36 = load i32*, i32** %4
%37 = call i32 @fputc(i32 0, i32* %36)
%38 = load i32*, i32** %4
%39 = call i32 @fputc(i32 88, i32* %38)
%40 = load i32*, i32** %4
%41 = call i32 @fputc(i32 2, i32* %40)
store i32 0, i32* %3
br label %42
42: ; preds = %9, %8
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [5 x i8] c"FUJI\00"
@.str.1 = [5 x i8] c"baud\00"
define i32 @sio_write_cas_header(i32* %0, i8* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = tail call i32 @rewind(i32* %0)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4, i64 1, i32* %0)
%7 = tail call i32 @strlen(i8* %1)
%8 = and i32 %7, 255
%9 = tail call i32 @fputc(i32 %8, i32* %0)
%10 = tail call i32 @strlen(i8* %1)
%11 = lshr i32 %10, 8
%12 = and i32 %11, 255
%13 = tail call i32 @fputc(i32 %12, i32* %0)
%14 = tail call i32 @fputc(i32 0, i32* %0)
%15 = tail call i32 @fputc(i32 0, i32* %0)
%16 = tail call i32 @fputs(i8* %1, i32* %0)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4, i64 1, i32* %0)
%18 = tail call i32 @fputc(i32 0, i32* %0)
%19 = tail call i32 @fputc(i32 0, i32* %0)
%20 = tail call i32 @fputc(i32 88, i32* %0)
%21 = tail call i32 @fputc(i32 2, i32* %0)
br label %22
22: ; preds = %2, %4
%23 = phi i32 [ 0, %4 ], [ -1, %2 ]
ret i32 %23
}