#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char strlen(char *);
int main(int argc, char **argv) {
  char b[128], i;
  if (argc < 3) {
    printf("binary <1|2> <string>\n");
    return 1;
  }
  for (i = 0; i < strlen(argv[2]); i++) {
    if (atoi(argv[1]) == 1) {
      argv[2][i]++;
    } else {
      argv[2][i]--;
    }
  }
  strcpy(b, argv[2]);
  printf("%s\n", b);
  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   $0x3,-0x8(%rbp)
jge    117d <main+0x3d>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1246 <main+0x106>
movb   $0x0,-0x91(%rbp)
movsbl -0x91(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    %al,%cl
mov    -0x98(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jge    1216 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
cmp    $0x1,%eax
jne    11e5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbq -0x91(%rbp),%rcx
ff
mov    (%rax,%rcx,1),%dl
add    $0x1,%dl
mov    %dl,(%rax,%rcx,1)
jmp    11fe <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbq -0x91(%rbp),%rcx
ff
mov    (%rax,%rcx,1),%dl
add    $0xff,%dl
mov    %dl,(%rax,%rcx,1)
jmp    1203 <main+0xc3>
mov    -0x91(%rbp),%al
add    $0x1,%al
mov    %al,-0x91(%rbp)
jmp    1184 <main+0x44>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
cmp    $0x3,%edi
jge    1162 <main+0x22>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    11cc <main+0x8c>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
call   1050 <strlen@plt>
test   %al,%al
jle    11b3 <main+0x73>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%r14),%rdi
call   1060 <atoi@plt>
cmp    $0x1,%eax
sete   %al
mov    0x10(%r14),%rcx
add    %al,%al
add    (%rcx,%rbx,1),%al
add    $0xff,%al
mov    %al,(%rcx,%rbx,1)
add    $0x1,%rbx
mov    0x10(%r14),%rdi
call   1050 <strlen@plt>
movsbq %al,%rax
cmp    %rax,%rbx
jl     1180 <main+0x40>
mov    0x10(%r14),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"binary <1|2> <string>\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %58
12: ; preds = %2
store i8 0, i8* %7
br label %13
13: ; preds = %47, %12
%14 = load i8, i8* %7
%15 = sext i8 %14 to i32
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call signext i8 @strlen(i8* %18)
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %15, %20
br i1 %21, label %22, label %50
22: ; preds = %13
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %37
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = load i8, i8* %7
%33 = sext i8 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = add i8 %35, 1
store i8 %36, i8* %34
br label %46
37: ; preds = %22
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = load i8, i8* %7
%42 = sext i8 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = add i8 %44, -1
store i8 %45, i8* %43
br label %46
46: ; preds = %37, %28
br label %47
47: ; preds = %46
%48 = load i8, i8* %7
%49 = add i8 %48, 1
store i8 %49, i8* %7
br label %13
50: ; preds = %13
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32 @strcpy(i8* %51, i8* %54)
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %56)
store i32 0, i32* %3
br label %58
58: ; preds = %50, %10
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@str = [22 x i8] c"binary <1|2> <string>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call signext i8 @strlen(i8* %8)
%10 = icmp sgt i8 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 1
br label %15
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %34
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %25, %15 ]
%17 = load i8*, i8** %12
%18 = tail call i32 @atoi(i8* %17)
%19 = icmp eq i32 %18, 1
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 %16
%22 = load i8, i8* %21
%23 = select i1 %19, i8 1, i8 -1
%24 = add i8 %22, %23
store i8 %24, i8* %21
%25 = add nuw nsw i64 %16, 1
%26 = load i8*, i8** %7
%27 = tail call signext i8 @strlen(i8* %26)
%28 = sext i8 %27 to i64
%29 = icmp slt i64 %25, %28
br i1 %29, label %15, label %30
30: ; preds = %15, %6
%31 = load i8*, i8** %7
%32 = call i32 @strcpy(i8* %4, i8* %31)
%33 = call i32 @puts(i8* %4)
br label %34
34: ; preds = %30, %13
%35 = phi i32 [ 1, %13 ], [ 0, %30 ]
ret i32 %35
}