#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void read_mondai(char mondai[], FILE *fp) {
  char line[100];
  int p = 0;
  while (!feof(fp)) {
    memset(line, 0, 100);
    fgets(line, 100, fp);
    int len = strlen(line);
    if (line[len - 1] == '\n') {
      line[len - 1] = '\0';
      len--;
    }
    if (len < (3 * 3)) {
      strcat(line, "         ");
    }
    strncpy(&mondai[p], line, (3 * 3));
    p += (3 * 3);
    mondai[p] = '\0';
  }
}


x86 assembly (clang, -O0):
<read_mondai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119b <read_mondai+0x3b>
jmp    1260 <read_mondai+0x100>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1204 <read_mondai+0xa4>
mov    -0x88(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x88(%rbp)
cmpl   $0x9,-0x88(%rbp)
jge    1221 <read_mondai+0xc1>
lea    -0x80(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
movslq -0x84(%rbp),%rax
add    %rax,%rdi
lea    -0x80(%rbp),%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
mov    -0x84(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x84(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    117d <read_mondai+0x1d>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mondai>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1189 <read_mondai+0x29>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
lea    0xe6d(%rip),%r12
jmp    11c4 <read_mondai+0x64>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x9(%rbx)
add    $0x9,%rbx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    117d <read_mondai+0x1d>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
cmpb   $0xa,-0x1(%rsp,%rcx,1)
jne    11ff <read_mondai+0x9f>
add    $0xffffffffffffffff,%rcx
movb   $0x0,(%rsp,%rcx,1)
mov    %ecx,%eax
cmp    $0x8,%eax
jg     11a0 <read_mondai+0x40>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
jmp    11a0 <read_mondai+0x40>

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

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