#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*/ STDOUT_FILENO;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void printbufs(char **buf, int nbytes) {
  int j;
  fflush(stdout);
  for (j = 0; j < 512; j++) {
    write(STDOUT_FILENO, buf[j], nbytes);
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printbufs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x200,-0x10(%rbp)
jge    1198 <printbufs+0x68>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0xc(%rbp),%edx
call   1030 <write@plt>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <printbufs+0x24>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbufs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %ebp,%ebp
mov    0x2e9c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
mov    (%rbx,%rbp,8),%rsi
mov    %r14d,%edx
call   1040 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x200,%rbp
jne    1160 <printbufs+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@STDOUT_FILENO = global i32 0
define void @printbufs(i8** nocapture %0, i32 %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @fflush(i32 %3)
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %12, %5 ]
%7 = load i32, i32* @STDOUT_FILENO
%8 = getelementptr inbounds i8*, i8** %0, i64 %6
%9 = load i8*, i8** %8
%10 = tail call i32 @write(i32 %7, i8* %9, i32 %1)
%11 = tail call i32 @putchar(i32 10)
%12 = add nuw nsw i64 %6, 1
%13 = icmp eq i64 %12, 512
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = tail call i32 @putchar(i32 10)
ret void
}