#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*/ getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strnncat(char *, char *, int);
int strnncmp(char *, char *, int);
int /*<<< orphan*/ strnncpy(char *, char *, int);
int main() {
  int n;
  n = 3;
  char a[100];
  char b[100];
  getline(a, 100);
  getline(b, 100);
  strnncpy(a, b, n);
  printf("%s\t%s\n", a, b);
  printf("Insert second line\n");
  getline(b, 100);
  strnncat(a, b, n);
  printf("%s\t%s\n", a, b);
  printf("Insert second line\n");
  getline(b, 100);
  printf("%s\t%s\t%d\n", a, b, strnncmp(a, b, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1070 <getline@plt>
lea    -0xe0(%rbp),%rdi
mov    $0x64,%esi
call   1070 <getline@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <strnncpy@plt>
lea    -0x70(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    $0x64,%esi
call   1070 <getline@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <strnncat@plt>
lea    -0x70(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    $0x64,%esi
call   1070 <getline@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1060 <strnncmp@plt>
mov    -0xf0(%rbp),%rsi
mov    -0xe8(%rbp),%rdx
mov    %eax,%ecx
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1080 <getline@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <getline@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1040 <strnncpy@plt>
lea    0xe59(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe53(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <getline@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <strnncat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <getline@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1070 <strnncmp@plt>
lea    0xde8(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s\09%s\0A\00"
@.str.1 = [20 x i8] c"Insert second line\0A\00"
@.str.2 = [10 x i8] c"%s\09%s\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
store i32 0, i32* %1
store i32 3, i32* %2
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i32 @getline(i8* %5, i32 100)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i32 @getline(i8* %7, i32 100)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @strnncpy(i8* %9, i8* %10, i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i32 @getline(i8* %17, i32 100)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = load i32, i32* %2
%22 = call i32 @strnncat(i8* %19, i8* %20, i32 %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%28 = call i32 @getline(i8* %27, i32 100)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%33 = load i32, i32* %2
%34 = call i32 @strnncmp(i8* %31, i8* %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30, i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s\09%s\0A\00"
@.str.2 = [10 x i8] c"%s\09%s\09%d\0A\00"
@str.3 = [19 x i8] c"Insert second line\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 100)
%6 = call i32 @getline(i8* %4, i32 100)
%7 = call i32 @strnncpy(i8* %3, i8* %4, i32 3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.3, i64 0, i64 0))
%10 = call i32 @getline(i8* %4, i32 100)
%11 = call i32 @strnncat(i8* %3, i8* %4, i32 3)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.3, i64 0, i64 0))
%14 = call i32 @getline(i8* %4, i32 100)
%15 = call i32 @strnncmp(i8* %3, i8* %4, i32 3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* %4, i32 %15)
ret i32 0
}