#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*/ scanf(char *, char *);
int /*<<< orphan*/ swap(char *, int);
int main() {
  char s[100];
  int x = 0;
  scanf("%s", s);
  for (int j = 0; j < 100; j++) {
    if (s[j] == '\0') {
      x = j;
      break;
    }
  }
  swap(s, x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1030 <scanf@plt>
movl   $0x0,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    118a <main+0x6a>
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    1177 <main+0x57>
mov    -0x78(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    118a <main+0x6a>
jmp    117c <main+0x5c>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1150 <main+0x30>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1040 <swap@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
lea    0xed5(%rip),%rdi
mov    %rsp,%rsi
call   1030 <scanf@plt>
mov    $0x4,%esi
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,-0x4(%rsp,%rsi,1)
je     1170 <main+0x50>
cmpb   $0x0,-0x3(%rsp,%rsi,1)
je     1176 <main+0x56>
cmpb   $0x0,-0x2(%rsp,%rsi,1)
je     117c <main+0x5c>
cmpb   $0x0,-0x1(%rsp,%rsi,1)
je     1182 <main+0x62>
cmpb   $0x0,(%rsp,%rsi,1)
je     1186 <main+0x66>
add    $0x5,%rsi
cmp    $0x68,%rsi
jne    1140 <main+0x20>
xor    %esi,%esi
jmp    1186 <main+0x66>
add    $0xfffffffffffffffc,%rsi
jmp    1186 <main+0x66>
add    $0xfffffffffffffffd,%rsi
jmp    1186 <main+0x66>
add    $0xfffffffffffffffe,%rsi
jmp    1186 <main+0x66>
add    $0xffffffffffffffff,%rsi
mov    %rsp,%rdi
call   1040 <swap@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %4
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = load i32, i32* %4
store i32 %18, i32* %3
br label %23
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %7
23: ; preds = %17, %7
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%25 = load i32, i32* %3
%26 = call i32 @swap(i8* %24, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %4
4: ; preds = %29, %0
%5 = phi i64 [ 0, %0 ], [ %30, %29 ]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %32, label %9
9: ; preds = %4
%10 = add nuw nsw i64 %5, 1
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %32, label %14
14: ; preds = %9
%15 = add nuw nsw i64 %5, 2
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %14
%20 = add nuw nsw i64 %5, 3
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %32, label %24
24: ; preds = %19
%25 = add nuw nsw i64 %5, 4
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = add nuw nsw i64 %5, 5
%31 = icmp eq i64 %30, 100
br i1 %31, label %35, label %4
32: ; preds = %24, %19, %14, %9, %4
%33 = phi i64 [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %20, %19 ], [ %25, %24 ]
%34 = trunc i64 %33 to i32
br label %35
35: ; preds = %29, %32
%36 = phi i32 [ %34, %32 ], [ 0, %29 ]
%37 = call i32 @swap(i8* %2, i32 %36)
ret i32 0
}