#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 */
char getchar();
void input(char str[], int key, int size) {
  if (key >= size - 1) {
    str[size - 1] = '\0';
    return;
  }
  str[key] = getchar();
  input(str, key + 1, size);
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1159 <input+0x39>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    117f <input+0x5f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <input@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    -0x1(%rdx),%r15d
cmp    %esi,%r15d
jle    1153 <input+0x43>
mov    %esi,%ebx
movslq %esi,%r12
add    %r14,%r12
not    %ebx
add    %edx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,(%r12,%rbp,1)
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    1140 <input+0x30>
movslq %r15d,%rax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @input(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = load i32, i32* %6
%9 = sub nsw i32 %8, 1
%10 = icmp sge i32 %7, %9
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8 0, i8* %16
br label %27
17: ; preds = %3
%18 = call signext i8 (...) @getchar()
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %6
br label %27
27: ; preds = %17, %11
ret void
}

LLVM IR (-O2):
define void @input(i8* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp sgt i32 %4, %1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = sext i32 %1 to i64
br label %11
8: ; preds = %11, %3
%9 = sext i32 %4 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
ret void
11: ; preds = %6, %11
%12 = phi i64 [ %7, %6 ], [ %15, %11 ]
%13 = tail call signext i8 (...) @getchar()
%14 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 %13, i8* %14
%15 = add nsw i64 %12, 1
%16 = trunc i64 %15 to i32
%17 = icmp eq i32 %4, %16
br i1 %17, label %8, label %11
}