#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(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, short);
void columnwrite(FILE *filepointer, short *column, char *format, short arg,
                 int newlines) {
  char outstring[10];
  short i;
  sprintf(outstring, format, arg);
  for (i = 0; outstring[i] != 0; ++i) {
    if (newlines) {
      if (*column >= 64) {
        fputs("\\\n", filepointer);
        *column = 0;
      }
    }
    fputc(outstring[i], filepointer);
    ++*column;
  }
}


x86 assembly (clang, -O0):
<columnwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
mov    %r8d,-0x20(%rbp)
lea    -0x2a(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movswl -0x1a(%rbp),%edx
call   1050 <sprintf@plt>
movw   $0x0,-0x2c(%rbp)
movswq -0x2c(%rbp),%rax
movsbl -0x2a(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11e5 <columnwrite+0xb5>
cmpl   $0x0,-0x20(%rbp)
je     11b1 <columnwrite+0x81>
mov    -0x10(%rbp),%rax
movswl (%rax),%eax
cmp    $0x40,%eax
jl     11ac <columnwrite+0x7c>
mov    -0x8(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x10(%rbp),%rax
movw   $0x0,(%rax)
jmp    11b1 <columnwrite+0x81>
movswq -0x2c(%rbp),%rax
mov    -0x2a(%rbp,%rax,1),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%cx
add    $0x1,%cx
mov    %cx,(%rax)
mov    -0x2c(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2c(%rbp)
jmp    1166 <columnwrite+0x36>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<columnwrite>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %rsi,%r13
mov    %rdi,%r12
lea    0xe(%rsp),%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
call   1040 <sprintf@plt>
mov    0xe(%rsp),%bl
test   %bl,%bl
je     11bc <columnwrite+0x8c>
mov    $0x1,%bp
lea    0xe97(%rip),%r15
jmp    1191 <columnwrite+0x61>
nopl   0x0(%rax,%rax,1)
movsbl %bl,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
addw   $0x1,0x0(%r13)
movswq %bp,%rax
movzbl 0xe(%rsp,%rax,1),%ebx
add    $0x1,%ebp
test   %bl,%bl
je     11bc <columnwrite+0x8c>
test   %r14d,%r14d
je     1170 <columnwrite+0x40>
cmpw   $0x40,0x0(%r13)
jl     1170 <columnwrite+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r12,%rcx
call   1050 <fwrite@plt>
movw   $0x0,0x0(%r13)
jmp    1170 <columnwrite+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\\\0A\00"
define void @columnwrite(i32* nocapture %0, i16* nocapture %1, i8* nocapture %2, i16 signext %3, i32 %4) {
%6 = alloca [10 x i8]
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) %2, i16 signext %3)
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %30, label %11
11: ; preds = %5
%12 = icmp eq i32 %4, 0
br label %13
13: ; preds = %11, %21
%14 = phi i8 [ %9, %11 ], [ %28, %21 ]
%15 = phi i16 [ 0, %11 ], [ %25, %21 ]
br i1 %12, label %21, label %16
16: ; preds = %13
%17 = load i16, i16* %1
%18 = icmp sgt i16 %17, 63
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
store i16 0, i16* %1
br label %21
21: ; preds = %16, %19, %13
%22 = tail call i32 @fputc(i8 signext %14, i32* %0)
%23 = load i16, i16* %1
%24 = add i16 %23, 1
store i16 %24, i16* %1
%25 = add i16 %15, 1
%26 = sext i16 %25 to i64
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %13
30: ; preds = %21, %5
ret void
}