#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 */
scalar_t__ mkdir(char const *, int);
int /*<<< orphan*/ perror(char const *);
void do_mkdir(int argc, const char **argv) {
  while (argc-- > 1) {
    if (mkdir(argv[1], 0777) < 0)
      perror(argv[1]);
    argv++;
  }
}


x86 assembly (clang, -O0):
<do_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x1,%eax
jle    117d <do_mkdir+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jge    116c <do_mkdir+0x4c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <perror@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    112f <do_mkdir+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_mkdir>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1168 <do_mkdir+0x48>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%ebp
add    $0x8,%rbx
jmp    114c <do_mkdir+0x2c>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x2,%ebp
jbe    1168 <do_mkdir+0x48>
mov    (%rbx),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
jns    1140 <do_mkdir+0x20>
mov    (%rbx),%rdi
call   1040 <perror@plt>
jmp    1140 <do_mkdir+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @do_mkdir(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
br label %5
5: ; preds = %20, %2
%6 = load i32, i32* %3
%7 = add nsw i32 %6, -1
store i32 %7, i32* %3
%8 = icmp sgt i32 %6, 1
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @mkdir(i8* %12, i32 511)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @perror(i8* %18)
br label %20
20: ; preds = %15, %9
%21 = load i8**, i8*** %4
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %4
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @do_mkdir(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %17
4: ; preds = %2, %15
%5 = phi i32 [ %7, %15 ], [ %0, %2 ]
%6 = phi i8** [ %8, %15 ], [ %1, %2 ]
%7 = add nsw i32 %5, -1
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @mkdir(i8* %9, i32 511)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i8*, i8** %8
%14 = tail call i32 @perror(i8* %13)
br label %15
15: ; preds = %12, %4
%16 = icmp ugt i32 %5, 2
br i1 %16, label %4, label %17
17: ; preds = %15, %2
ret void
}