#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*/ printf(char *);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
int main(int argc, char *argv[]) {
  char buff[1024 + 1];
  if (1 < argc && argv[1][0] != 0) {
    size_t len = strlen(argv[1]);
    strncpy(buff, argv[1], (len < 1024) ? len : 1024);
  } else {
    fgets(buff, 1024, stdin);
  }
  printf(buff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    1200 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1200 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x430(%rbp)
cmpq   $0x400,-0x428(%rbp)
jae    11d0 <main+0x90>
mov    -0x428(%rbp),%rax
mov    %rax,-0x440(%rbp)
jmp    11e1 <main+0xa1>
mov    $0x400,%eax
mov    %rax,-0x440(%rbp)
jmp    11e1 <main+0xa1>
mov    -0x430(%rbp),%rsi
mov    -0x438(%rbp),%rdi
mov    -0x440(%rbp),%rdx
call   1030 <strncpy@plt>
jmp    121a <main+0xda>
lea    -0x420(%rbp),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    -0x420(%rbp),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
cmp    $0x2,%edi
jl     117a <main+0x3a>
mov    0x8(%rsi),%rbx
cmpb   $0x0,(%rbx)
je     117a <main+0x3a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x400,%rax
mov    $0x400,%edx
cmovb  %rax,%rdx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
jmp    1190 <main+0x50>
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    %rsp,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1025 x i8]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 1, %8
br i1 %9, label %10, label %35
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %10
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %7
%23 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i64, i64* %7
%28 = icmp ult i64 %27, 1024
br i1 %28, label %29, label %31
29: ; preds = %18
%30 = load i64, i64* %7
br label %32
31: ; preds = %18
br label %32
32: ; preds = %31, %29
%33 = phi i64 [ %30, %29 ], [ 1024, %31 ]
%34 = call i32 @strncpy(i8* %23, i8* %26, i64 %33)
br label %39
35: ; preds = %10, %2
%36 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%37 = load i32, i32* @stdin
%38 = call i32 @fgets(i8* %36, i32 1024, i32 %37)
br label %39
39: ; preds = %35, %32
%40 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%41 = call i32 @printf(i8* %40)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1025 x i8]
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = tail call i64 @strlen(i8* %8)
%13 = icmp ult i64 %12, 1024
%14 = select i1 %13, i64 %12, i64 1024
%15 = call i32 @strncpy(i8* %4, i8* %8, i64 %14)
br label %19
16: ; preds = %6, %2
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %4, i32 1024, i32 %17)
br label %19
19: ; preds = %16, %11
%20 = call i32 @printf(i8* %4)
ret i32 0
}