#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 *readargnumber(char *, int *);
char *readdesignator(char *arg, int designator[]) {
  if (*arg == '*') {
    designator[0] = 1;
    return ++arg;
  }
  if (*arg == '-')
    arg++;
  else {
    arg = readargnumber(arg, &designator[0]);
    if (*arg == '-')
      arg++;
    else {
      designator[1] = designator[0];
      return arg;
    }
  }
  return readargnumber(arg, &designator[1]);
}


x86 assembly (clang, -O0):
<readdesignator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    114f <readdesignator+0x3f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11d6 <readdesignator+0xc6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1170 <readdesignator+0x60>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <readdesignator+0xb1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <readargnumber@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11a2 <readdesignator+0x92>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11bc <readdesignator+0xac>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <readdesignator+0xc6>
jmp    11c1 <readdesignator+0xb1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
call   1030 <readargnumber@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readdesignator>:
push   %rbx
mov    %rsi,%rbx
mov    (%rdi),%al
cmp    $0x2d,%al
je     113a <readdesignator+0x2a>
cmp    $0x2a,%al
jne    112a <readdesignator+0x1a>
movl   $0x1,(%rbx)
add    $0x1,%rdi
jmp    1150 <readdesignator+0x40>
mov    %rbx,%rsi
call   1030 <readargnumber@plt>
mov    %rax,%rdi
cmpb   $0x2d,(%rax)
jne    114b <readdesignator+0x3b>
add    $0x1,%rdi
add    $0x4,%rbx
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <readargnumber@plt>
mov    (%rbx),%eax
mov    %eax,0x4(%rbx)
mov    %rdi,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @readdesignator(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 42
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 0
store i32 1, i32* %12
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
store i8* %14, i8** %3
br label %48
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 45
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
br label %43
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 0
%27 = call i8* @readargnumber(i8* %24, i32* %26)
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 45
br i1 %31, label %32, label %35
32: ; preds = %23
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
br label %42
35: ; preds = %23
%36 = load i32*, i32** %5
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = load i32, i32* %37
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i64 1
store i32 %38, i32* %40
%41 = load i8*, i8** %4
store i8* %41, i8** %3
br label %48
42: ; preds = %32
br label %43
43: ; preds = %42, %20
%44 = load i8*, i8** %4
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 1
%47 = call i8* @readargnumber(i8* %44, i32* %46)
store i8* %47, i8** %3
br label %48
48: ; preds = %43, %35, %10
%49 = load i8*, i8** %3
ret i8* %49
}

LLVM IR (-O2):
define i8* @readdesignator(i8* %0, i32* %1) {
%3 = load i8, i8* %0
switch i8 %3, label %6 [
i8 42, label %4
i8 45, label %13
]
4: ; preds = %2
store i32 1, i32* %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
br label %18
6: ; preds = %2
%7 = tail call i8* @readargnumber(i8* %0, i32* %1)
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %11, i32* %12
br label %18
13: ; preds = %6, %2
%14 = phi i8* [ %0, %2 ], [ %7, %6 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = getelementptr inbounds i32, i32* %1, i64 1
%17 = tail call i8* @readargnumber(i8* %15, i32* %16)
br label %18
18: ; preds = %13, %10, %4
%19 = phi i8* [ %5, %4 ], [ %17, %13 ], [ %7, %10 ]
ret i8* %19
}