#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*/ isprint(char);
int /*<<< orphan*/ putchar(char);
int rand();
void generate_password(int len) {
  char c;
  int i;
  for (i = 0; i < len; ++i) {
    do {
      c = rand() % 127;
    } while (!isprint(c));
    putchar(c);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<generate_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1197 <generate_password+0x67>
jmp    1153 <generate_password+0x23>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x7f,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1153 <generate_password+0x23>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <generate_password+0x12>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_password>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    1185 <generate_password+0x55>
mov    %edi,%r14d
xor    %ebp,%ebp
nopl   (%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x6,%ebx
add    %ecx,%ebx
mov    %ebx,%ecx
shl    $0x7,%ecx
sub    %ecx,%ebx
add    %eax,%ebx
movsbl %bl,%edi
call   1040 <isprint@plt>
test   %eax,%eax
je     1140 <generate_password+0x10>
movsbl %bl,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %r14d,%ebp
jne    1140 <generate_password+0x10>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @generate_password(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %25
9: ; preds = %5
br label %10
10: ; preds = %14, %9
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 127
%13 = trunc i32 %12 to i8
store i8 %13, i8* %3
br label %14
14: ; preds = %10
%15 = load i8, i8* %3
%16 = call i32 @isprint(i8 signext %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %10, label %19
19: ; preds = %14
%20 = load i8, i8* %3
%21 = call i32 @putchar(i8 signext %20)
br label %22
22: ; preds = %19
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %5
25: ; preds = %5
%26 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @generate_password(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %16
3: ; preds = %1, %11
%4 = phi i32 [ %14, %11 ], [ 0, %1 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 127
%8 = trunc i32 %7 to i8
%9 = tail call i32 @isprint(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = trunc i32 %7 to i8
%13 = tail call i32 @putchar(i8 signext %12)
%14 = add nuw nsw i32 %4, 1
%15 = icmp eq i32 %14, %0
br i1 %15, label %16, label %3
16: ; preds = %11, %1
%17 = tail call i32 @putchar(i8 signext 10)
ret void
}