#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();
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ sscanf(char *, char const *, void *);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
void io_getdata(const char *tip, const char *fmt, int slen, void *p) {
  int rc;
  int i;
  char input[1024];
  while (1) {
    printf("%s", tip);
    for (i = 0; (input[i] = getchar()) != '\n'; i++)
      ;
    input[i] = 0;
    if (i > 0) {
      if (!strcmp(input, "...")) {
        break;
      } else if (slen == 0 || (slen > 0 && strlen(input) == slen)) {
        sscanf(input, fmt, p);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<io_getdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
movslq -0x28(%rbp),%rcx
mov    %al,-0x430(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     11b2 <io_getdata+0x62>
jmp    11a4 <io_getdata+0x54>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1181 <io_getdata+0x31>
movslq -0x28(%rbp),%rax
movb   $0x0,-0x430(%rbp,%rax,1)
cmpl   $0x0,-0x28(%rbp)
jle    1235 <io_getdata+0xe5>
lea    -0x430(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e9 <io_getdata+0x99>
jmp    123a <io_getdata+0xea>
cmpl   $0x0,-0x14(%rbp)
je     1212 <io_getdata+0xc2>
cmpl   $0x0,-0x14(%rbp)
jle    122b <io_getdata+0xdb>
lea    -0x430(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x14(%rbp),%eax
jne    122b <io_getdata+0xdb>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <sscanf@plt>
jmp    123a <io_getdata+0xea>
jmp    1230 <io_getdata+0xe0>
jmp    1235 <io_getdata+0xe5>
jmp    116a <io_getdata+0x1a>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_getdata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rcx,0x8(%rsp)
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe9b(%rip),%r12
lea    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0xffffffffffffffff,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,0x11(%rsp,%r14,1)
add    $0x1,%r14
cmp    $0xa,%al
jne    1190 <io_getdata+0x50>
mov    %r14d,%eax
movb   $0x0,0x10(%rsp,%rax,1)
test   %r14d,%r14d
je     1170 <io_getdata+0x30>
cmpl   $0x2e2e2e,0x10(%rsp)
je     11df <io_getdata+0x9f>
test   %ebp,%ebp
je     11cd <io_getdata+0x8d>
jle    1170 <io_getdata+0x30>
mov    %r13,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jne    1170 <io_getdata+0x30>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    0x8(%rsp),%rdx
call   1060 <sscanf@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"...\00"
define void @io_getdata(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
br label %12
12: ; preds = %4, %55
%13 = load i8*, i8** %5
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %10
br label %15
15: ; preds = %23, %12
%16 = call signext i8 (...) @getchar()
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %18
store i8 %16, i8* %19
%20 = sext i8 %16 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %26
22: ; preds = %15
br label %23
23: ; preds = %22
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
store i32 %25, i32* %10
br label %15
26: ; preds = %15
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %28
store i8 0, i8* %29
%30 = load i32, i32* %10
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %55
32: ; preds = %26
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
br label %56
37: ; preds = %32
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 0
br i1 %39, label %48, label %40
40: ; preds = %37
%41 = load i32, i32* %7
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = load i32, i32* %7
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %43, %37
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%50 = load i8*, i8** %6
%51 = load i8*, i8** %8
%52 = call i32 @sscanf(i8* %49, i8* %50, i8* %51)
br label %56
53: ; preds = %43, %40
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54, %26
br label %12
56: ; preds = %48, %36
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @io_getdata(i8* %0, i8* nocapture %1, i32 %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = bitcast [1024 x i8]* %5 to i32*
%8 = icmp eq i32 %2, 0
%9 = icmp sgt i32 %2, 0
br label %10
10: ; preds = %31, %4
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ %17, %12 ], [ 0, %10 ]
%14 = call signext i8 (...) @getchar()
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %13
store i8 %14, i8* %15
%16 = icmp eq i8 %14, 10
%17 = add nuw i64 %13, 1
br i1 %16, label %18, label %12
18: ; preds = %12
%19 = trunc i64 %13 to i32
%20 = and i64 %13, 4294967295
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %20
store i8 0, i8* %21
%22 = icmp eq i32 %19, 0
br i1 %22, label %31, label %23
23: ; preds = %18
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 3026478
br i1 %25, label %34, label %26
26: ; preds = %23
br i1 %8, label %32, label %27
27: ; preds = %26
br i1 %9, label %28, label %31
28: ; preds = %27
%29 = call i32 @strlen(i8* %6)
%30 = icmp eq i32 %29, %2
br i1 %30, label %32, label %31
31: ; preds = %28, %27, %18
br label %10
32: ; preds = %28, %26
%33 = call i32 @sscanf(i8* %6, i8* %1, i8* %3)
br label %34
34: ; preds = %23, %32
ret void
}