#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 *dynamic_cat(char *, size_t *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int read_punct(char *s[], char *rezult[], size_t *rezult_size, char delim[]) {
  char tmp[2];
  sscanf(*s, "%1s", tmp);
  ++*s;
  char *test;
  if (!(test = dynamic_cat(*rezult, rezult_size, tmp)))
    return -1;
  else
    *rezult = test;
  if (!(test = dynamic_cat(*rezult, rezult_size, delim)))
    return -1;
  else
    *rezult = test;
  return 0;
}


x86 assembly (clang, -O0):
<read_punct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x2a(%rbp),%rdx
lea    0xeb6(%rip),%rsi
call   1030 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1040 <dynamic_cat@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    118b <read_punct+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <read_punct+0xb6>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <dynamic_cat@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11c4 <read_punct+0xa4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <read_punct+0xb6>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_punct>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    (%rdi),%rdi
lea    0xebe(%rip),%rsi
lea    0xe(%rsp),%r12
mov    %r12,%rdx
call   1030 <sscanf@plt>
addq   $0x1,0x0(%rbp)
mov    (%r15),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1040 <dynamic_cat@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1187 <read_punct+0x67>
mov    %rax,(%r15)
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <dynamic_cat@plt>
test   %rax,%rax
je     1187 <read_punct+0x67>
mov    %rax,(%r15)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%1s\00"
define i32 @read_punct(i8** %0, i8** %1, i64* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca [2 x i8]
%11 = alloca i8*
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i64* %2, i64** %8
store i8* %3, i8** %9
%12 = load i8**, i8*** %6
%13 = load i8*, i8** %12
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%15 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8**, i8*** %6
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %16
%19 = load i8**, i8*** %7
%20 = load i8*, i8** %19
%21 = load i64*, i64** %8
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%23 = call i8* @dynamic_cat(i8* %20, i64* %21, i8* %22)
store i8* %23, i8** %11
%24 = icmp ne i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %4
store i32 -1, i32* %5
br label %41
26: ; preds = %4
%27 = load i8*, i8** %11
%28 = load i8**, i8*** %7
store i8* %27, i8** %28
br label %29
29: ; preds = %26
%30 = load i8**, i8*** %7
%31 = load i8*, i8** %30
%32 = load i64*, i64** %8
%33 = load i8*, i8** %9
%34 = call i8* @dynamic_cat(i8* %31, i64* %32, i8* %33)
store i8* %34, i8** %11
%35 = icmp ne i8* %34, null
br i1 %35, label %37, label %36
36: ; preds = %29
store i32 -1, i32* %5
br label %41
37: ; preds = %29
%38 = load i8*, i8** %11
%39 = load i8**, i8*** %7
store i8* %38, i8** %39
br label %40
40: ; preds = %37
store i32 0, i32* %5
br label %41
41: ; preds = %40, %36, %25
%42 = load i32, i32* %5
ret i32 %42
}

LLVM IR (-O2):
@.str = [4 x i8] c"%1s\00"
define i32 @read_punct(i8** nocapture %0, i8** nocapture %1, i64* %2, i8* %3) {
%5 = alloca [2 x i8]
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%7 = load i8*, i8** %0
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%9 = load i8*, i8** %0
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** %0
%11 = load i8*, i8** %1
%12 = call i8* @dynamic_cat(i8* %11, i64* %2, i8* %6)
%13 = icmp eq i8* %12, null
br i1 %13, label %18, label %14
14: ; preds = %4
store i8* %12, i8** %1
%15 = call i8* @dynamic_cat(i8* %12, i64* %2, i8* %3)
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14
store i8* %15, i8** %1
br label %18
18: ; preds = %14, %4, %17
%19 = phi i32 [ 0, %17 ], [ -1, %4 ], [ -1, %14 ]
ret i32 %19
}