#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int writechars(char *lines[], int norows) {
  int err = 1, i, j;
  char *pl;
  for (i = 0; i < norows; i++, lines++) {
    if (i > 23) {
      err = -1;
      break;
    }
    pl = *lines;
    j = 0;
    while (*pl) {
      if (j >= 80) {
        err = -1;
        break;
      }
      putchar(*pl);
      fflush(stdout);
      usleep(10000);
      pl++;
      j++;
    }
    putchar('\n');
    fflush(stdout);
  }
  return err;
}


x86 assembly (clang, -O0):
<writechars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1214 <writechars+0xe4>
cmpl   $0x17,-0x14(%rbp)
jle    116f <writechars+0x3f>
movl   $0xffffffff,-0x10(%rbp)
jmp    1214 <writechars+0xe4>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e2 <writechars+0xb2>
cmpl   $0x50,-0x18(%rbp)
jl     11a4 <writechars+0x74>
movl   $0xffffffff,-0x10(%rbp)
jmp    11e2 <writechars+0xb2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x2710,%edi
call   1050 <usleep@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <writechars+0x51>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    114d <writechars+0x1d>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writechars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11d0 <writechars+0xa0>
mov    %esi,%r15d
mov    %rdi,%r13
movl   $0x1,0x4(%rsp)
xor    %ebp,%ebp
mov    0x2e86(%rip),%r12
jmp    1187 <writechars+0x57>
nopl   0x0(%rax)
movl   $0xffffffff,0x4(%rsp)
ff
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r12),%edi
call   1040 <fflush@plt>
add    $0x1,%ebp
add    $0x8,%r13
cmp    %r15d,%ebp
je     11e2 <writechars+0xb2>
cmp    $0x18,%ebp
je     11da <writechars+0xaa>
mov    0x0(%r13),%rbx
mov    (%rbx),%al
test   %al,%al
je     1168 <writechars+0x38>
mov    $0x1,%r14d
nopl   0x0(%rax)
cmp    $0x51,%r14d
je     1160 <writechars+0x30>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    (%r12),%edi
call   1040 <fflush@plt>
mov    $0x2710,%edi
call   1050 <usleep@plt>
movzbl (%rbx,%r14,1),%eax
add    $0x1,%r14
test   %al,%al
jne    11a0 <writechars+0x70>
jmp    1168 <writechars+0x38>
movl   $0x1,0x4(%rsp)
jmp    11e2 <writechars+0xb2>
movl   $0xffffffff,0x4(%rsp)
ff
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
define i32 @writechars(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %43, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %48
13: ; preds = %9
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 23
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 -1, i32* %5
br label %48
17: ; preds = %13
%18 = load i8**, i8*** %3
%19 = load i8*, i8** %18
store i8* %19, i8** %8
store i32 0, i32* %7
br label %20
20: ; preds = %28, %17
%21 = load i8*, i8** %8
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %20
%25 = load i32, i32* %7
%26 = icmp sge i32 %25, 80
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 -1, i32* %5
br label %39
28: ; preds = %24
%29 = load i8*, i8** %8
%30 = load i8, i8* %29
%31 = call i32 @putchar(i8 signext %30)
%32 = load i32, i32* @stdout
%33 = call i32 @fflush(i32 %32)
%34 = call i32 @usleep(i32 10000)
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %8
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %20
39: ; preds = %27, %20
%40 = call i32 @putchar(i8 signext 10)
%41 = load i32, i32* @stdout
%42 = call i32 @fflush(i32 %41)
br label %43
43: ; preds = %39
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
%46 = load i8**, i8*** %3
%47 = getelementptr inbounds i8*, i8** %46, i32 1
store i8** %47, i8*** %3
br label %9
48: ; preds = %16, %9
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @writechars(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %35
4: ; preds = %2, %27
%5 = phi i32 [ %32, %27 ], [ 0, %2 ]
%6 = phi i32 [ %28, %27 ], [ 1, %2 ]
%7 = phi i8** [ %33, %27 ], [ %0, %2 ]
%8 = icmp eq i32 %5, 24
br i1 %8, label %35, label %9
9: ; preds = %4
%10 = load i8*, i8** %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %9, %18
%14 = phi i8 [ %25, %18 ], [ %11, %9 ]
%15 = phi i8* [ %23, %18 ], [ %10, %9 ]
%16 = phi i32 [ %24, %18 ], [ 0, %9 ]
%17 = icmp eq i32 %16, 80
br i1 %17, label %27, label %18
18: ; preds = %13
%19 = tail call i32 @putchar(i8 signext %14)
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
%22 = tail call i32 @usleep(i32 10000)
%23 = getelementptr inbounds i8, i8* %15, i64 1
%24 = add nuw nsw i32 %16, 1
%25 = load i8, i8* %23
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %13
27: ; preds = %18, %13, %9
%28 = phi i32 [ %6, %9 ], [ -1, %13 ], [ %6, %18 ]
%29 = tail call i32 @putchar(i8 signext 10)
%30 = load i32, i32* @stdout
%31 = tail call i32 @fflush(i32 %30)
%32 = add nuw nsw i32 %5, 1
%33 = getelementptr inbounds i8*, i8** %7, i64 1
%34 = icmp eq i32 %32, %1
br i1 %34, label %35, label %4
35: ; preds = %27, %4, %2
%36 = phi i32 [ 1, %2 ], [ -1, %4 ], [ %28, %27 ]
ret i32 %36
}