#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*/ error(char **, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int test(int, char **);
int main(int argc, char *argv[]) {
  int arg0len;
  arg0len = strlen(argv[0]);
  if (argv[0][arg0len - 1] == '[') {
    if (strcmp(argv[argc - 1], "]") != 0)
      error(argv, "Missing ']'");
    argc--;
  }
  if ((argc = test(argc - 1, argv + 1)) == 2)
    error(argv, "syntax error");
  return argc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    11c2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b9 <main+0x79>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1050 <error@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1060 <test@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x2,%eax
jne    11f1 <main+0xb1>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1050 <error@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1030 <strlen@plt>
mov    (%rbx),%rcx
cltq
cmpb   $0x5b,-0x1(%rax,%rcx,1)
jne    1187 <main+0x47>
movslq %ebp,%rax
add    $0xffffffff,%ebp
mov    -0x8(%rbx,%rax,8),%rdi
lea    0xe92(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1187 <main+0x47>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1050 <error@plt>
add    $0xffffffff,%ebp
lea    0x8(%rbx),%rsi
mov    %ebp,%edi
call   1060 <test@plt>
mov    %eax,%ebp
cmp    $0x2,%eax
jne    11ab <main+0x6b>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <error@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"]\00"
@.str.1 = [12 x i8] c"Missing ']'\00"
@.str.2 = [13 x i8] c"syntax error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 91
br i1 %20, label %21, label %36
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = load i8**, i8*** %5
%32 = call i32 @error(i8** %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %30, %21
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %36
36: ; preds = %33, %2
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = call i32 @test(i32 %38, i8** %40)
store i32 %41, i32* %4
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %46
43: ; preds = %36
%44 = load i8**, i8*** %5
%45 = call i32 @error(i8** %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %43, %36
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@.str = [2 x i8] c"]\00"
@.str.1 = [12 x i8] c"Missing ']'\00"
@.str.2 = [13 x i8] c"syntax error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @strlen(i8* %3)
%5 = load i8*, i8** %1
%6 = add nsw i32 %4, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 91
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = add nsw i32 %0, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = tail call i32 @error(i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %11, %18, %2
%21 = phi i32 [ %0, %2 ], [ %12, %18 ], [ %12, %11 ]
%22 = add nsw i32 %21, -1
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = tail call i32 @test(i32 %22, i8** %23)
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @error(i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
ret i32 %24
}