#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 */
scalar_t__ read_chk_line(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int read_more_sat(int n, char *p) {
  char line[2048];
  do {
    p += 36;
    if (read_chk_line(line))
      return 1;
    if (line[2] == ' ') {
      sprintf(p, "%s", &line[32]);
    } else {
      sprintf(p, "%s", &line[0]);
    }
    n -= 12;
  } while (n > 12);
  return 0;
}


x86 assembly (clang, -O0):
<read_more_sat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x24,%rax
mov    %rax,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
call   1030 <read_chk_line@plt>
cmp    $0x0,%rax
je     1160 <read_more_sat+0x40>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <read_more_sat+0xa1>
movsbl -0x80e(%rbp),%eax
cmp    $0x20,%eax
jne    1190 <read_more_sat+0x70>
mov    -0x10(%rbp),%rdi
lea    -0x810(%rbp),%rdx
add    $0x20,%rdx
lea    0xe7a(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11a7 <read_more_sat+0x87>
mov    -0x10(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe5e(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jg     1132 <read_more_sat+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_more_sat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x20(%rsp),%r15
add    $0xc,%ebp
add    $0x24,%rbx
mov    %rsp,%r14
jmp    1164 <read_more_sat+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0xfffffff4,%ebp
add    $0x24,%rbx
cmp    $0x18,%ebp
jle    1180 <read_more_sat+0x60>
mov    %r14,%rdi
call   1040 <read_chk_line@plt>
test   %rax,%rax
jne    1184 <read_more_sat+0x64>
cmpb   $0x20,0x2(%rsp)
mov    %r15,%rsi
je     1150 <read_more_sat+0x30>
mov    %r14,%rsi
jmp    1150 <read_more_sat+0x30>
xor    %eax,%eax
jmp    1189 <read_more_sat+0x69>
mov    $0x1,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @read_more_sat(i32 %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 32
br label %7
7: ; preds = %13, %2
%8 = phi i32 [ %0, %2 ], [ %18, %13 ]
%9 = phi i8* [ %1, %2 ], [ %10, %13 ]
%10 = getelementptr inbounds i8, i8* %9, i64 36
%11 = call i64 @read_chk_line(i8* %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %7
%14 = load i8, i8* %5
%15 = icmp eq i8 %14, 32
%16 = select i1 %15, i8* %6, i8* %4
%17 = call i8* @strcpy(i8* %10, i8* %16)
%18 = add nsw i32 %8, -12
%19 = icmp sgt i32 %8, 24
br i1 %19, label %7, label %20
20: ; preds = %13, %7
%21 = phi i32 [ 1, %7 ], [ 0, %13 ]
ret i32 %21
}