#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 */
typedef int /*<<< orphan*/ format;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, char const *);
int scanf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int, char const *);
int testnl();
void getstrpar(const char *s, char *r, int l, const char *t) {
  int i;
  char format[20];
  int f;
  if (t == 0)
    t = " \t\n;";
  (void)snprintf(format, sizeof(format), "%%%d[^%s]", l, t);
  while (1) {
    if ((f = testnl()) && s)
      printf("%s: ", s);
    if (f)
      getchar();
    scanf("%*[\t ;]");
    i = scanf(format, r);
    if (i < 0)
      exit(1);
    if (i != 0)
      return;
  }
}


x86 assembly (clang, -O0):
<getstrpar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118d <getstrpar+0x2d>
lea    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x14,%esi
lea    0xe61(%rip),%rdx
call   1040 <snprintf@plt>
mov    $0x0,%al
call   1080 <testnl@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
je     11d7 <getstrpar+0x77>
cmpq   $0x0,-0x8(%rbp)
je     11d7 <getstrpar+0x77>
mov    -0x8(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x44(%rbp)
je     11e8 <getstrpar+0x88>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    121c <getstrpar+0xbc>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     122c <getstrpar+0xcc>
add    $0x50,%rsp
pop    %rbp
ret
jmp    11a9 <getstrpar+0x49>

x86 assembly (clang, -O2):
<getstrpar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%eax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rcx,%rcx
lea    0xe80(%rip),%r8
cmovne %rcx,%r8
lea    0xe7a(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1040 <snprintf@plt>
lea    0xe6b(%rip),%r12
lea    0xe69(%rip),%r13
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <testnl@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     11cd <getstrpar+0x6d>
test   %ebp,%ebp
je     11cd <getstrpar+0x6d>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
test   %ebp,%ebp
je     11d8 <getstrpar+0x78>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
test   %eax,%eax
js     1204 <getstrpar+0xa4>
je     11b0 <getstrpar+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0A;\00"
@.str.1 = [10 x i8] c"%%%d[^%s]\00"
@.str.2 = [5 x i8] c"%s: \00"
@.str.3 = [8 x i8] c"%*[\09 ;]\00"
define void @getstrpar(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 [20 x i8]
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = load i8*, i8** %8
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
br label %15
15: ; preds = %14, %4
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%17 = load i32, i32* %7
%18 = load i8*, i8** %8
%19 = call i32 @snprintf(i8* %16, i32 20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %18)
br label %20
20: ; preds = %15, %47
%21 = call i32 (...) @testnl()
store i32 %21, i32* %11
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i8*, i8** %5
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %23, %20
%30 = load i32, i32* %11
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (...) @getchar()
br label %34
34: ; preds = %32, %29
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @scanf(i8* %36, i8* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %34
%44 = load i32, i32* %9
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %43
ret void
47: ; preds = %43
br label %20
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0A;\00"
@.str.1 = [10 x i8] c"%%%d[^%s]\00"
@.str.2 = [5 x i8] c"%s: \00"
@.str.3 = [8 x i8] c"%*[\09 ;]\00"
define void @getstrpar(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [20 x i8]
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%7 = icmp eq i8* %3, null
%8 = select i1 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3
%9 = call i32 @snprintf(i8* %6, i32 20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %8)
%10 = icmp ne i8* %0, null
br label %11
11: ; preds = %26, %4
%12 = call i32 (...) @testnl()
%13 = icmp ne i32 %12, 0
%14 = and i1 %10, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %17
17: ; preds = %15, %11
br i1 %13, label %18, label %20
18: ; preds = %17
%19 = call i32 (...) @getchar()
br label %20
20: ; preds = %18, %17
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* %6, i8* %1)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %20
%27 = icmp eq i32 %22, 0
br i1 %27, label %11, label %28
28: ; preds = %26
ret void
}