#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 *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *, int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char data[160];
  char name[160];
  char expression[160];
  int x, counter, address;
  int all_names = 0;
  char *p;
  char *q = "";
  x = argc;
  while (x--) {
    if (x == 0)
      break;
    if (strcmp(argv[x], "all") == 0)
      all_names = 1;
    else
      q = argv[x];
  }
  for (;;) {
    p = fgets(data, 160, stdin);
    if (p == NULL)
      break;
    if (data[0] == '+') {
      x = sscanf(data + 1, "%[^:]:%s", name, expression);
      if (expression[0] == '$') {
        if (all_names == 0)
          continue;
        sscanf(expression + 1, "%x:%x", &counter, &address);
      } else
        sscanf(expression, "%x", &address);
      printf("%s %s=%d\n", q, name, address);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x200(%rbp)
lea    0xeb2(%rip),%rax
mov    %rax,-0x210(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1f4(%rbp)
mov    -0x1f4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1f4(%rbp)
cmp    $0x0,%eax
je     11f5 <main+0xb5>
cmpl   $0x0,-0x1f4(%rbp)
jne    11a6 <main+0x66>
jmp    11f5 <main+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x1f4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe44(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <main+0x9a>
movl   $0x1,-0x200(%rbp)
jmp    11f0 <main+0xb0>
mov    -0x10(%rbp),%rax
movslq -0x1f4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x210(%rbp)
jmp    117a <main+0x3a>
jmp    11fa <main+0xba>
lea    -0xb0(%rbp),%rdi
mov    0x2de0(%rip),%rax
mov    (%rax),%edx
mov    $0xa0,%esi
call   1040 <fgets@plt>
mov    %rax,-0x208(%rbp)
cmpq   $0x0,-0x208(%rbp)
jne    122e <main+0xee>
jmp    12fa <main+0x1ba>
movsbl -0xb0(%rbp),%eax
cmp    $0x2b,%eax
jne    12f5 <main+0x1b5>
lea    -0xb0(%rbp),%rdi
add    $0x1,%rdi
lea    -0x150(%rbp),%rdx
lea    -0x1f0(%rbp),%rcx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x1f4(%rbp)
movsbl -0x1f0(%rbp),%eax
cmp    $0x24,%eax
jne    12b9 <main+0x179>
cmpl   $0x0,-0x200(%rbp)
jne    128d <main+0x14d>
jmp    11fa <main+0xba>
lea    -0x1f0(%rbp),%rdi
add    $0x1,%rdi
lea    0xd6e(%rip),%rsi
lea    -0x1f8(%rbp),%rdx
lea    -0x1fc(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
jmp    12d5 <main+0x195>
lea    -0x1f0(%rbp),%rdi
lea    0xd49(%rip),%rsi
lea    -0x1fc(%rbp),%rdx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    -0x210(%rbp),%rsi
lea    -0x150(%rbp),%rdx
mov    -0x1fc(%rbp),%ecx
lea    0xd23(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <main+0xba>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
cmp    $0x2,%edi
jae    1245 <main+0x105>
lea    0xebb(%rip),%r15
xor    %r12d,%r12d
mov    0x2e7d(%rip),%rbx
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0xa0,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1231 <main+0xf1>
mov    %r15,%rbp
lea    0x150(%rsp),%r13
lea    0xb0(%rsp),%r14
lea    0x10(%rsp),%r15
jmp    11e0 <main+0xa0>
nop
mov    %r14,%rdi
lea    0xe66(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
mov    0x8(%rsp),%ecx
lea    0xe52(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1030 <printf@plt>
mov    (%rbx),%edx
mov    %r15,%rdi
mov    $0xa0,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1231 <main+0xf1>
cmpb   $0x2b,0x10(%rsp)
jne    11cc <main+0x8c>
lea    0x11(%rsp),%rdi
lea    0xe11(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmpb   $0x24,0xb0(%rsp)
24
jne    11a0 <main+0x60>
test   %r12d,%r12d
je     11cc <main+0x8c>
lea    0xb1(%rsp),%rdi
lea    0xdef(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
jmp    11b6 <main+0x76>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    -0x1(%rdi),%eax
cltq
lea    (%rsi,%rax,8),%rbx
mov    $0x1,%r13d
sub    %edi,%r13d
xor    %ebp,%ebp
lea    0xdbc(%rip),%r15
xor    %r14d,%r14d
jmp    1280 <main+0x140>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbp
mov    %r12d,%r14d
cmp    %ebp,%r13d
je     1164 <main+0x24>
mov    (%rbx,%rbp,8),%rdi
lea    0xd75(%rip),%rsi
call   1050 <strcmp@plt>
mov    $0x1,%r12d
test   %rax,%rax
je     1270 <main+0x130>
mov    (%rbx,%rbp,8),%r15
mov    %r14d,%r12d
jmp    1270 <main+0x130>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"all\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%[^:]:%s\00"
@.str.3 = [6 x i8] c"%x:%x\00"
@.str.4 = [3 x i8] c"%x\00"
@.str.5 = [10 x i8] c"%s %s=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [160 x i8]
%7 = alloca [160 x i8]
%8 = alloca [160 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = load i32, i32* %4
store i32 %15, i32* %9
br label %16
16: ; preds = %39, %2
%17 = load i32, i32* %9
%18 = add nsw i32 %17, -1
store i32 %18, i32* %9
%19 = icmp ne i32 %17, 0
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
br label %40
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %24
store i32 1, i32* %12
br label %39
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %14
br label %39
39: ; preds = %33, %32
br label %16
40: ; preds = %23, %16
br label %41
41: ; preds = %79, %66, %40
%42 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 0
%43 = load i32, i32* @stdin
%44 = call i8* @fgets(i8* %42, i32 160, i32 %43)
store i8* %44, i8** %13
%45 = load i8*, i8** %13
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %48
47: ; preds = %41
br label %80
48: ; preds = %41
%49 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 43
br i1 %52, label %53, label %79
53: ; preds = %48
%54 = getelementptr inbounds [160 x i8], [160 x i8]* %6, i64 0, i64 0
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = getelementptr inbounds [160 x i8], [160 x i8]* %7, i64 0, i64 0
%57 = getelementptr inbounds [160 x i8], [160 x i8]* %8, i64 0, i64 0
%58 = call i32 (i8*, i8*, ...) @sscanf(i8* %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %56, i8* %57)
store i32 %58, i32* %9
%59 = getelementptr inbounds [160 x i8], [160 x i8]* %8, i64 0, i64 0
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 36
br i1 %62, label %63, label %71
63: ; preds = %53
%64 = load i32, i32* %12
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %63
br label %41
67: ; preds = %63
%68 = getelementptr inbounds [160 x i8], [160 x i8]* %8, i64 0, i64 0
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = call i32 (i8*, i8*, ...) @sscanf(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %10, i32* %11)
br label %74
71: ; preds = %53
%72 = getelementptr inbounds [160 x i8], [160 x i8]* %8, i64 0, i64 0
%73 = call i32 (i8*, i8*, ...) @sscanf(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %11)
br label %74
74: ; preds = %71, %67
%75 = load i8*, i8** %14
%76 = getelementptr inbounds [160 x i8], [160 x i8]* %7, i64 0, i64 0
%77 = load i32, i32* %11
%78 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %75, i8* %76, i32 %77)
br label %79
79: ; preds = %74, %48
br label %41
80: ; preds = %47
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"all\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%[^:]:%s\00"
@.str.3 = [6 x i8] c"%x:%x\00"
@.str.4 = [3 x i8] c"%x\00"
@.str.5 = [10 x i8] c"%s %s=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [160 x i8]
%4 = alloca [160 x i8]
%5 = alloca [160 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [160 x i8], [160 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = icmp ult i32 %0, 2
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = add i32 %0, -1
%16 = sext i32 %15 to i64
br label %27
17: ; preds = %37, %2
%18 = phi i32 [ 0, %2 ], [ %38, %37 ]
%19 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ %39, %37 ]
%20 = load i32, i32* @stdin
%21 = call i8* @fgets(i8* %8, i32 160, i32 %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %62, label %23
23: ; preds = %17
%24 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 1
%25 = icmp eq i32 %18, 0
%26 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 1
br label %43
27: ; preds = %14, %37
%28 = phi i64 [ %16, %14 ], [ %40, %37 ]
%29 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %14 ], [ %39, %37 ]
%30 = phi i32 [ 0, %14 ], [ %38, %37 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %28
%32 = load i8*, i8** %31
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %27
%36 = load i8*, i8** %31
br label %37
37: ; preds = %27, %35
%38 = phi i32 [ %30, %35 ], [ 1, %27 ]
%39 = phi i8* [ %36, %35 ], [ %29, %27 ]
%40 = add nsw i64 %28, -1
%41 = trunc i64 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %17, label %27
43: ; preds = %23, %58
%44 = load i8, i8* %8
%45 = icmp eq i8 %44, 43
br i1 %45, label %46, label %58
46: ; preds = %43
%47 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
%48 = load i8, i8* %10
%49 = icmp eq i8 %48, 36
br i1 %49, label %50, label %53
50: ; preds = %46
br i1 %25, label %58, label %51
51: ; preds = %50
%52 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %7)
br label %55
53: ; preds = %46
%54 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
br label %55
55: ; preds = %53, %51
%56 = load i32, i32* %7
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %19, i8* %9, i32 %56)
br label %58
58: ; preds = %43, %55, %50
%59 = load i32, i32* @stdin
%60 = call i8* @fgets(i8* %8, i32 160, i32 %59)
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %43
62: ; preds = %58, %17
ret i32 0
}