#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*/ write(int, char *, int);
void putfinal(char *str, int size, int *j, int p) {
  int pad2;
  int pad1;
  pad1 = (size - p);
  pad2 = ((size - p) / 2) - 1;
  while (--pad1)
    write(1, " ", 1);
  while (str[p]) {
    write(1, &str[p], 1);
    ++p;
  }
  while (--pad2)
    write(1, " ", 1);
  write(1, "\n", 1);
  *j = size;
}


x86 assembly (clang, -O0):
<putfinal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     116d <putfinal+0x5d>
mov    $0x1,%edx
lea    0xe9f(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    1143 <putfinal+0x33>
jmp    1172 <putfinal+0x62>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11a9 <putfinal+0x99>
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <putfinal+0x62>
jmp    11ae <putfinal+0x9e>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     11d8 <putfinal+0xc8>
mov    $0x1,%edx
lea    0xe34(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    11ae <putfinal+0x9e>
mov    $0x1,%edx
lea    0xe1e(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putfinal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %esi,%eax
sub    %ecx,%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
cmp    $0x1,%eax
je     1167 <putfinal+0x57>
mov    %r14d,%r12d
sub    %r15d,%r12d
add    $0x1,%r12d
lea    0xeb7(%rip),%r13
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
inc    %r12d
jne    1150 <putfinal+0x40>
sar    %ebp
movslq %r14d,%rax
cmpb   $0x0,(%rbx,%rax,1)
je     119c <putfinal+0x8c>
add    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1180 <putfinal+0x70>
add    $0xfffffffe,%ebp
je     11c7 <putfinal+0xb7>
lea    0xe58(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0xffffffff,%ebp
jne    11b0 <putfinal+0xa0>
lea    0xe34(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    (%rsp),%rax
mov    %r15d,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @putfinal(i8* nocapture %0, i32 %1, i32* nocapture writeonly %2, i32 %3) {
%5 = sub nsw i32 %1, %3
%6 = sdiv i32 %5, 2
%7 = add nsw i32 %5, -1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %14, %4
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %19, label %22
14: ; preds = %4, %14
%15 = phi i32 [ %17, %14 ], [ %7, %4 ]
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%17 = add nsw i32 %15, -1
%18 = icmp eq i32 %17, 0
br i1 %18, label %9, label %14
19: ; preds = %22, %9
%20 = add nsw i32 %6, -2
%21 = icmp eq i32 %20, 0
br i1 %21, label %35, label %30
22: ; preds = %9, %22
%23 = phi i64 [ %26, %22 ], [ %10, %9 ]
%24 = phi i8* [ %27, %22 ], [ %11, %9 ]
%25 = tail call i32 @write(i32 1, i8* %24, i32 1)
%26 = add i64 %23, 1
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %19, label %22
30: ; preds = %19, %30
%31 = phi i32 [ %33, %30 ], [ %20, %19 ]
%32 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%33 = add nsw i32 %31, -1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %30
35: ; preds = %30, %19
%36 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 %1, i32* %2
ret void
}