#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char input[64];
  int x;
  printf("Command: ");
  fgets(input, 64, stdin);
  for (x = 0; x < 64; x++) {
    if (input[x] == '\\') {
      input[x] = '/';
      continue;
    }
    if (input[x] == '\n') {
      input[x] = '\0';
      break;
    }
  }
  printf("The command is '%s'\n", input);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1040 <fgets@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x40,-0x54(%rbp)
jge    11b8 <main+0x98>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x5c,%eax
jne    1185 <main+0x65>
movslq -0x54(%rbp),%rax
movb   $0x2f,-0x50(%rbp,%rax,1)
jmp    11aa <main+0x8a>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11a5 <main+0x85>
movslq -0x54(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
jmp    11b8 <main+0x98>
jmp    11aa <main+0x8a>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115b <main+0x3b>
lea    -0x50(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2eaf(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1040 <fgets@plt>
lea    0x3(%rsp),%rax
mov    $0x40,%ecx
jmp    116d <main+0x4d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,(%rax)
add    $0x4,%rax
add    $0xfffffffffffffffc,%rcx
je     11e6 <main+0xc6>
movzbl -0x3(%rax),%edx
cmp    $0x5c,%dl
je     1180 <main+0x60>
cmp    $0xa,%dl
jne    1184 <main+0x64>
jmp    11d3 <main+0xb3>
nopl   (%rax)
movb   $0x2f,-0x3(%rax)
movzbl -0x2(%rax),%edx
cmp    $0x5c,%dl
je     11a0 <main+0x80>
cmp    $0xa,%dl
jne    11a4 <main+0x84>
jmp    11d9 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,-0x2(%rax)
movzbl -0x1(%rax),%edx
cmp    $0x5c,%dl
je     11c0 <main+0xa0>
cmp    $0xa,%dl
jne    11c4 <main+0xa4>
jmp    11df <main+0xbf>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,-0x1(%rax)
movzbl (%rax),%edx
cmp    $0x5c,%dl
je     1160 <main+0x40>
cmp    $0xa,%dl
jne    1163 <main+0x43>
jmp    11e3 <main+0xc3>
add    $0xfffffffffffffffd,%rax
jmp    11e3 <main+0xc3>
add    $0xfffffffffffffffe,%rax
jmp    11e3 <main+0xc3>
add    $0xffffffffffffffff,%rax
movb   $0x0,(%rax)
lea    0xe1d(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Command: \00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"The command is '%s'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 64, i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 64
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 92
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %20
store i8 47, i8* %21
br label %34
22: ; preds = %11
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %31
store i8 0, i8* %32
br label %37
33: ; preds = %22
br label %34
34: ; preds = %33, %18
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %8
37: ; preds = %29, %8
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Command: \00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"The command is '%s'\0A\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 64, i32 %4)
br label %6
6: ; preds = %28, %0
%7 = phi i64 [ 0, %0 ], [ %29, %28 ]
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %13 [
i8 92, label %10
i8 10, label %11
]
10: ; preds = %6
store i8 47, i8* %8
br label %13
11: ; preds = %23, %18, %13, %6
%12 = phi i8* [ %8, %6 ], [ %15, %13 ], [ %20, %18 ], [ %25, %23 ]
store i8 0, i8* %12
br label %31
13: ; preds = %6, %10
%14 = or i64 %7, 1
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
switch i8 %16, label %18 [
i8 92, label %17
i8 10, label %11
]
17: ; preds = %13
store i8 47, i8* %15
br label %18
18: ; preds = %17, %13
%19 = or i64 %7, 2
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
switch i8 %21, label %23 [
i8 92, label %22
i8 10, label %11
]
22: ; preds = %18
store i8 47, i8* %20
br label %23
23: ; preds = %22, %18
%24 = or i64 %7, 3
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
switch i8 %26, label %28 [
i8 92, label %27
i8 10, label %11
]
27: ; preds = %23
store i8 47, i8* %25
br label %28
28: ; preds = %27, %23
%29 = add nuw nsw i64 %7, 4
%30 = icmp eq i64 %29, 64
br i1 %30, label %31, label %6
31: ; preds = %28, %11
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}