#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*/ printf(char *, ...);
int strlen(char *);
void main(void) {
  char *foo = "/vsitypes/1/";
  char *c;
  char z;
  int s = strlen(foo);
  int x = 0;
  int y = 0;
  char version[32];
  char id[32];
  printf("%d\n\n", s);
  for (c = foo; *c; c++) {
    z = (char)c[0];
    if (y == 2) {
      if (z != '/') {
        version[x] = z;
        x++;
      }
    }
    if (y == 3) {
      id[x] = z;
      x++;
    }
    if (z == '/') {
      y++;
      if (y == 2) {
        x = 0;
      } else if (y == 3) {
        version[x] = '\0';
        x = 0;
      }
    }
  }
  id[x] = '\0';
  printf("\n version is %s\nid is %s\n idlen = %d", version, id, strlen(id));
  printf("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1230 <main+0x110>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmpl   $0x2,-0x20(%rbp)
jne    11ac <main+0x8c>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
je     11a7 <main+0x87>
mov    -0x11(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x8c>
cmpl   $0x3,-0x20(%rbp)
jne    11ca <main+0xaa>
mov    -0x11(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
jne    121a <main+0xfa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jne    11f6 <main+0xd6>
movl   $0x0,-0x1c(%rbp)
jmp    1215 <main+0xf5>
cmpl   $0x3,-0x20(%rbp)
jne    1210 <main+0xf0>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
movl   $0x0,-0x1c(%rbp)
jmp    1215 <main+0xf5>
jmp    121a <main+0xfa>
jmp    121f <main+0xff>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1166 <main+0x46>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    %eax,%ecx
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
lea    0xec3(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xec1(%rip),%rdi
xor    %ebp,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2f,%dl
mov    $0x1,%eax
xor    %ecx,%ecx
jmp    1175 <main+0x45>
add    $0x1,%ebp
mov    %esi,%ecx
movzbl (%rax,%rbx,1),%edx
add    $0x1,%rax
cmp    $0xd,%rax
je     11d9 <main+0xa9>
cmp    $0x2,%ebp
jne    1190 <main+0x60>
cmp    $0x2f,%dl
je     1190 <main+0x60>
movslq %ecx,%rsi
mov    %dl,0x20(%rsp,%rsi,1)
add    $0x1,%ecx
mov    $0x2,%ebp
jmp    1167 <main+0x37>
cmp    $0x3,%ebp
jne    11b0 <main+0x80>
movslq %ecx,%rsi
mov    %dl,(%rsp,%rsi,1)
add    $0x1,%esi
cmp    $0x2f,%dl
jne    1165 <main+0x35>
jmp    11b7 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%esi
cmp    $0x2f,%dl
jne    1165 <main+0x35>
xor    %ecx,%ecx
cmp    $0x1,%ebp
je     11d2 <main+0xa2>
cmp    $0x2,%ebp
jne    1162 <main+0x32>
movslq %esi,%rdx
movb   $0x0,0x20(%rsp,%rdx,1)
mov    $0x3,%ebp
jmp    1167 <main+0x37>
mov    $0x2,%ebp
jmp    1167 <main+0x37>
movslq %ecx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe20(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"/vsitypes/1/\00"
@.str.1 = [5 x i8] c"%d\0A\0A\00"
@.str.2 = [37 x i8] c"\0A version is %s\0Aid is %s\0A idlen = %d\00"
@str = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %7
7: ; preds = %0, %34
%8 = phi i8 [ 47, %0 ], [ %38, %34 ]
%9 = phi i32 [ 0, %0 ], [ %36, %34 ]
%10 = phi i32 [ 0, %0 ], [ %35, %34 ]
%11 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %0 ], [ %37, %34 ]
%12 = icmp eq i32 %9, 2
%13 = icmp ne i8 %8, 47
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %19
15: ; preds = %7
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %16
store i8 %8, i8* %17
%18 = add nsw i32 %10, 1
br label %34
19: ; preds = %7
%20 = icmp eq i32 %9, 3
br i1 %20, label %21, label %25
21: ; preds = %19
%22 = sext i32 %10 to i64
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %22
store i8 %8, i8* %23
%24 = add nsw i32 %10, 1
br label %25
25: ; preds = %21, %19
%26 = phi i32 [ %24, %21 ], [ %10, %19 ]
%27 = icmp eq i8 %8, 47
br i1 %27, label %28, label %34
28: ; preds = %25
switch i32 %9, label %32 [
i32 1, label %34
i32 2, label %29
]
29: ; preds = %28
%30 = sext i32 %26 to i64
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %30
store i8 0, i8* %31
br label %34
32: ; preds = %28
%33 = add nsw i32 %9, 1
br label %34
34: ; preds = %15, %28, %32, %25, %29
%35 = phi i32 [ 0, %29 ], [ %26, %25 ], [ 0, %28 ], [ %26, %32 ], [ %18, %15 ]
%36 = phi i32 [ 3, %29 ], [ %9, %25 ], [ 2, %28 ], [ %33, %32 ], [ 2, %15 ]
%37 = getelementptr inbounds i8, i8* %11, i64 1
%38 = load i8, i8* %37
%39 = icmp eq i8* %37, getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 12)
br i1 %39, label %40, label %7
40: ; preds = %34
%41 = sext i32 %35 to i64
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %41
store i8 0, i8* %42
%43 = call i32 @strlen(i8* %5)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5, i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}