#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 putpad(char *str, int size, int *p) {
  int i;
  i = 0;
  while (i < 16 && *p < size) {
    write(1, &str[*p], 1);
    ++i;
    *p += 1;
  }
  write(1, "\n", 1);
  return;
}


x86 assembly (clang, -O0):
<putpad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jge    1148 <putpad+0x38>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1158 <putpad+0x48>
jmp    118b <putpad+0x7b>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq (%rax),%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)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    112a <putpad+0x1a>
mov    $0x1,%edx
lea    0xe69(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putpad>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %rdi,%r14
mov    (%rdx),%eax
mov    $0x10,%ebp
nopw   0x0(%rax,%rax,1)
cmp    %r15d,%eax
jge    1156 <putpad+0x46>
movslq %eax,%rsi
add    %r14,%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
add    $0xffffffff,%ebp
jne    1130 <putpad+0x20>
lea    0xea3(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @putpad(i8* nocapture %0, i32 %1, i32* nocapture %2) {
%4 = load i32, i32* %2
br label %5
5: ; preds = %3, %9
%6 = phi i32 [ %4, %3 ], [ %15, %9 ]
%7 = phi i32 [ 0, %3 ], [ %13, %9 ]
%8 = icmp slt i32 %6, %1
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = tail call i32 @write(i32 1, i8* %11, i32 1)
%13 = add nuw nsw i32 %7, 1
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = icmp eq i32 %13, 16
br i1 %16, label %17, label %5
17: ; preds = %9, %5
%18 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
ret void
}