#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mapper(char *, char *);
scalar_t__ split_kv_pair(char *, char **, char **);
int /*<<< orphan*/ stdin;
void run_mapper(void) {
  char line[1024 * 1024];
  char *key;
  char *val;
  while (fgets(line, 1024 * 1024, stdin) != NULL) {
    if (split_kv_pair(line, &key, &val))
      mapper(key, val);
  }
}


x86 assembly (clang, -O0):
<run_mapper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100010,%rsp
lea    -0x100000(%rbp),%rdi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
mov    $0x100000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     119b <run_mapper+0x6b>
lea    -0x100000(%rbp),%rdi
lea    -0x100008(%rbp),%rsi
lea    -0x100010(%rbp),%rdx
call   1050 <split_kv_pair@plt>
cmp    $0x0,%rax
je     1196 <run_mapper+0x66>
mov    -0x100008(%rbp),%rdi
mov    -0x100010(%rbp),%rsi
call   1030 <mapper@plt>
jmp    113b <run_mapper+0xb>
add    $0x100010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_mapper>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100018,%rsp
mov    0x2ea3(%rip),%r12
mov    (%r12),%edx
lea    0x10(%rsp),%rdi
mov    $0x100000,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11a9 <run_mapper+0x79>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r14
mov    %rsp,%r15
jmp    1186 <run_mapper+0x56>
nopl   0x0(%rax)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x100000,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11a9 <run_mapper+0x79>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <split_kv_pair@plt>
test   %rax,%rax
je     1170 <run_mapper+0x40>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1030 <mapper@plt>
jmp    1170 <run_mapper+0x40>
add    $0x100018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
define void @run_mapper() {
%1 = alloca [1048576 x i8]
%2 = alloca i8*
%3 = alloca i8*
br label %4
4: ; preds = %17, %0
%5 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32* @fgets(i8* %5, i32 1048576, i32 %6)
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %1, i64 0, i64 0
%11 = call i64 @split_kv_pair(i8* %10, i8** %2, i8** %3)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = call i32 @mapper(i8* %14, i8* %15)
br label %17
17: ; preds = %13, %9
br label %4
18: ; preds = %4
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
define void @run_mapper() {
%1 = alloca [1048576 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %1, i64 0, i64 0
%5 = bitcast i8** %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %4, i32 1048576, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %21, label %10
10: ; preds = %0, %17
%11 = call i64 @split_kv_pair(i8* %4, i8** %2, i8** %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = call i32 @mapper(i8* %14, i8* %15)
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* @stdin
%19 = call i32* @fgets(i8* %4, i32 1048576, i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %10
21: ; preds = %17, %0
ret void
}