#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*/ line;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int sscanf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ urldecode(char *, char *);
void ckb_getline(char word1[(4 * 1024)], char word2[(4 * 1024)],
                 char word3[(4 * 1024)]) {
  char line[(4 * 1024) * 3 + 3];
  fgets(line, sizeof(line), stdin);
  word1[0] = word1[1] = word1[2] = 0;
  int res = sscanf(line, "%s %s %s", word1, word2, word3);
  if (res >= 1)
    urldecode(word1, word1);
  if (res >= 2)
    urldecode(word2, word2);
  if (res >= 3)
    urldecode(word3, word3);
  line[strlen(line) - 1] = 0;
}


x86 assembly (clang, -O0):
<ckb_getline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x3020(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    $0x3003,%esi
call   1040 <fgets@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x3020(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe5e(%rip),%rsi
call   1050 <sscanf@plt>
mov    %eax,-0x3024(%rbp)
cmpl   $0x1,-0x3024(%rbp)
jl     11c7 <ckb_getline+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <urldecode@plt>
cmpl   $0x2,-0x3024(%rbp)
jl     11e1 <ckb_getline+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <urldecode@plt>
cmpl   $0x3,-0x3024(%rbp)
jl     11fb <ckb_getline+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <urldecode@plt>
lea    -0x3020(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x3020(%rbp,%rax,1)
add    $0x3030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ckb_getline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3008,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x3003,%esi
call   1040 <fgets@plt>
movb   $0x0,0x2(%rbx)
movw   $0x0,(%rbx)
lea    0xe81(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <sscanf@plt>
test   %eax,%eax
jle    11c1 <ckb_getline+0x81>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <urldecode@plt>
cmp    $0x1,%ebp
je     11c1 <ckb_getline+0x81>
mov    %r15,%rdi
mov    %r15,%rsi
call   1060 <urldecode@plt>
cmp    $0x3,%ebp
jb     11c1 <ckb_getline+0x81>
mov    %r14,%rdi
mov    %r14,%rsi
call   1060 <urldecode@plt>
mov    %rsp,%rdi
call   1030 <strlen@plt>
add    $0x3008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [9 x i8] c"%s %s %s\00"
define void @ckb_getline(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [12291 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [12291 x i8], [12291 x i8]* %7, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 12291, i32 %10)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 2
store i8 0, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 0, i8* %17
%18 = getelementptr inbounds [12291 x i8], [12291 x i8]* %7, i64 0, i64 0
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20, i8* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp sge i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %3
%26 = load i8*, i8** %4
%27 = load i8*, i8** %4
%28 = call i32 @urldecode(i8* %26, i8* %27)
br label %29
29: ; preds = %25, %3
%30 = load i32, i32* %8
%31 = icmp sge i32 %30, 2
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i8*, i8** %5
%34 = load i8*, i8** %5
%35 = call i32 @urldecode(i8* %33, i8* %34)
br label %36
36: ; preds = %32, %29
%37 = load i32, i32* %8
%38 = icmp sge i32 %37, 3
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i8*, i8** %6
%41 = load i8*, i8** %6
%42 = call i32 @urldecode(i8* %40, i8* %41)
br label %43
43: ; preds = %39, %36
%44 = getelementptr inbounds [12291 x i8], [12291 x i8]* %7, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [12291 x i8], [12291 x i8]* %7, i64 0, i64 %47
store i8 0, i8* %48
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [9 x i8] c"%s %s %s\00"
define void @ckb_getline(i8* %0, i8* %1, i8* %2) {
%4 = alloca [12291 x i8]
%5 = getelementptr inbounds [12291 x i8], [12291 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 12291, i32 %6)
%8 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 1
store i8 0, i8* %9
store i8 0, i8* %0
%10 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %3
%13 = call i32 @urldecode(i8* %0, i8* %0)
%14 = icmp eq i32 %10, 1
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = call i32 @urldecode(i8* %1, i8* %1)
%17 = icmp ugt i32 %10, 2
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @urldecode(i8* %2, i8* %2)
br label %20
20: ; preds = %3, %12, %18, %15
%21 = call i32 @strlen(i8* %5)
ret void
}