#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 *dup(char *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
char *nnodup(char *, int *);
char *nodup(char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int strlen(char *);
char toupper(char);
int main(int argc, char **argv) {
  int i;
  if (argc != 2)
    exit(1);
  char *string = *(argv + 1);
  int dict[26];
  memset(dict, 0, 26 * sizeof(int));
  for (i = 0; i < strlen(string); i++)
    string[i] = toupper(string[i]);
  printf("nodup: %s\n", nodup(string, dict));
  printf("nnodup: %s\n", nnodup(string, dict));
  printf("dup: %s\n", dup(string, dict));
  int ii;
  for (i = 0; i < 26; i++) {
    putchar('A' + i);
    for (ii = 0; ii < dict[i]; ii++)
      putchar('=');
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bd <main+0x2d>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1090 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
cmp    %ecx,%eax
jge    1231 <main+0xa1>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e3 <main+0x53>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1080 <nodup@plt>
mov    %rax,%rsi
lea    0xdb6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   10a0 <nnodup@plt>
mov    %rax,%rsi
lea    0xd96(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <dup@plt>
mov    %rax,%rsi
lea    0xd7a(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1a,-0x14(%rbp)
jge    1304 <main+0x174>
mov    -0x14(%rbp),%eax
add    $0x41,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
movslq -0x14(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
jge    12ec <main+0x15c>
mov    $0x3d,%edi
call   1030 <putchar@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12b7 <main+0x127>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1295 <main+0x105>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
cmp    $0x2,%edi
jne    12a1 <main+0x111>
mov    0x8(%rsi),%r15
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1090 <memset@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11f1 <main+0x61>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11d0 <main+0x40>
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <nodup@plt>
lea    0xdfb(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <nnodup@plt>
lea    0xde0(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <dup@plt>
lea    0xdc9(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
xor    %ebx,%ebx
jmp    1264 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x1a,%rbx
je     1294 <main+0x104>
lea    0x41(%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%rsp,%rbx,4)
jle    1250 <main+0xc0>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    (%rsp,%rbx,4),%ebp
jl     1280 <main+0xf0>
jmp    1250 <main+0xc0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10b0 <exit@plt>

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

LLVM IR (-O2):
@.str = [11 x i8] c"nodup: %s\0A\00"
@.str.1 = [12 x i8] c"nnodup: %s\0A\00"
@.str.2 = [9 x i8] c"dup: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [26 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = bitcast [26 x i32]* %3 to i8*
%11 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 0
%12 = call i32 @memset(i32* %11, i32 0, i32 104)
%13 = call i32 @strlen(i8* %9)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %7, %15
%16 = phi i64 [ %20, %15 ], [ 0, %7 ]
%17 = getelementptr inbounds i8, i8* %9, i64 %16
%18 = load i8, i8* %17
%19 = call signext i8 @toupper(i8 signext %18)
store i8 %19, i8* %17
%20 = add nuw nsw i64 %16, 1
%21 = call i32 @strlen(i8* %9)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %7
%25 = call i8* @nodup(i8* %9, i32* %11)
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i8* @nnodup(i8* %9, i32* %11)
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i8* @dup(i8* %9, i32* %11)
%30 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %24, %45
%32 = phi i64 [ 0, %24 ], [ %47, %45 ]
%33 = trunc i64 %32 to i8
%34 = add nuw nsw i8 %33, 65
%35 = call i32 @putchar(i8 signext %34)
%36 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %32
%37 = load i32, i32* %36
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %31, %39
%40 = phi i32 [ %42, %39 ], [ 0, %31 ]
%41 = call i32 @putchar(i8 signext 61)
%42 = add nuw nsw i32 %40, 1
%43 = load i32, i32* %36
%44 = icmp slt i32 %42, %43
br i1 %44, label %39, label %45
45: ; preds = %39, %31
%46 = call i32 @putchar(i8 signext 10)
%47 = add nuw nsw i64 %32, 1
%48 = icmp eq i64 %47, 26
br i1 %48, label %49, label %31
49: ; preds = %45
ret i32 0
}