#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ processdir(char *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char c, musicpath[64] = "/media/sda/music", tmp[64];
  for (c = 'a'; c <= 'z'; ++c) {
    musicpath[9] = c;
    if (access(musicpath, F_OK) == 0) {
      strcpy(tmp, "/media/sda/_usic");
      tmp[9] = c;
      rename(musicpath, tmp);
      mkdir(musicpath, 0777);
      processdir(tmp);
      return 0;
    }
  }
  fprintf(stderr, "no /media/sd?/music found\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)
lea    -0x60(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
movb   $0x61,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
jg     1235 <main+0xc5>
mov    -0x11(%rbp),%al
mov    %al,-0x57(%rbp)
lea    -0x60(%rbp),%rdi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0x0,%rax
jne    1223 <main+0xb3>
lea    -0xa0(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x11(%rbp),%al
mov    %al,-0x97(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1090 <rename@plt>
lea    -0x60(%rbp),%rdi
mov    $0x1ff,%esi
call   1050 <mkdir@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <processdir@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0xe1>
jmp    1228 <main+0xb8>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11a2 <main+0x32>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x61,%bl
mov    0x2e2c(%rip),%r15
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %bl,0x9(%rsp)
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <access@plt>
test   %rax,%rax
je     11e3 <main+0x83>
add    $0x1,%bl
cmp    $0x7b,%bl
jne    11b0 <main+0x50>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1060 <fprintf@plt>
jmp    121e <main+0xbe>
lea    0xe56(%rip),%rsi
lea    0x40(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %bl,0x49(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <rename@plt>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1050 <mkdir@plt>
mov    %r14,%rdi
call   1030 <processdir@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.musicpath = [64 x i8] c"/media/sda/music\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@F_OK = global i32 0
@.str = [17 x i8] c"/media/sda/_usic\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"no /media/sd?/music found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca [64 x i8]
%8 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [64 x i8]* %7 to i8*
store i8 97, i8* %6
br label %10
10: ; preds = %34, %2
%11 = load i8, i8* %6
%12 = sext i8 %11 to i32
%13 = icmp sle i32 %12, 122
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load i8, i8* %6
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 9
store i8 %15, i8* %16
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%18 = load i32, i32* @F_OK
%19 = call i64 @access(i8* %17, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %14
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%24 = load i8, i8* %6
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 9
store i8 %24, i8* %25
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%28 = call i32 @rename(i8* %26, i8* %27)
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%30 = call i32 @mkdir(i8* %29, i32 511)
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%32 = call i32 @processdir(i8* %31)
store i32 0, i32* %3
br label %40
33: ; preds = %14
br label %34
34: ; preds = %33
%35 = load i8, i8* %6
%36 = add i8 %35, 1
store i8 %36, i8* %6
br label %10
37: ; preds = %10
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %40
40: ; preds = %37, %21
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@__const.main.musicpath = [64 x i8] c"/media/sda/music\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@F_OK = global i32 0
@.str = [17 x i8] c"/media/sda/_usic\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"no /media/sd?/music found\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 9
br label %8
8: ; preds = %2, %19
%9 = phi i8 [ 97, %2 ], [ %20, %19 ]
store i8 %9, i8* %7
%10 = load i32, i32* @F_OK
%11 = call i64 @access(i8* %5, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 9
store i8 %9, i8* %15
%16 = call i32 @rename(i8* %5, i8* %6)
%17 = call i32 @mkdir(i8* %5, i32 511)
%18 = call i32 @processdir(i8* %6)
br label %25
19: ; preds = %8
%20 = add nuw nsw i8 %9, 1
%21 = icmp eq i8 %20, 123
br i1 %21, label %22, label %8
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %13
ret i32 0
}