#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__ rand();
void fill_transmit_buffer(char *buffer, int size) {
  int i;
  for (i = 0; i < size; i++) {
    buffer[i] = (char)rand();
    if (buffer[i] < 32 || buffer[i] > 126 || buffer[i] == '%') {
      i--;
    }
  }
}


x86 assembly (clang, -O0):
<fill_transmit_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a1 <fill_transmit_buffer+0x91>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1185 <fill_transmit_buffer+0x75>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     1185 <fill_transmit_buffer+0x75>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
jne    118e <fill_transmit_buffer+0x7e>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1193 <fill_transmit_buffer+0x83>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <fill_transmit_buffer+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_transmit_buffer>:
push   %rbp
push   %r14
push   %rbx
test   %esi,%esi
jle    114d <fill_transmit_buffer+0x3d>
mov    %esi,%ebx
mov    %rdi,%r14
xor    %ebp,%ebp
nop
xor    %eax,%eax
call   1030 <rand@plt>
movslq %ebp,%rcx
mov    %al,(%r14,%rcx,1)
lea    -0x7f(%rax),%edx
cmp    $0xa1,%dl
setb   %dl
cmp    $0x25,%al
sete   %al
or     %dl,%al
movzbl %al,%eax
neg    %eax
lea    (%rcx,%rax,1),%ebp
add    $0x1,%ebp
cmp    %ebx,%ebp
jl     1120 <fill_transmit_buffer+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @fill_transmit_buffer(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %44, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %47
10: ; preds = %6
%11 = call i64 (...) @rand()
%12 = trunc i64 %11 to i8
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 %12, i8* %16
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp slt i32 %22, 32
br i1 %23, label %40, label %24
24: ; preds = %10
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp sgt i32 %30, 126
br i1 %31, label %40, label %32
32: ; preds = %24
%33 = load i8*, i8** %3
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 37
br i1 %39, label %40, label %43
40: ; preds = %32, %24, %10
%41 = load i32, i32* %5
%42 = add nsw i32 %41, -1
store i32 %42, i32* %5
br label %43
43: ; preds = %40, %32
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %6
47: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @fill_transmit_buffer(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %18
4: ; preds = %2, %4
%5 = phi i32 [ %16, %4 ], [ 0, %2 ]
%6 = tail call i64 (...) @rand()
%7 = trunc i64 %6 to i8
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %7, i8* %9
%10 = add i8 %7, -127
%11 = icmp ult i8 %10, -95
%12 = icmp eq i8 %7, 37
%13 = or i1 %12, %11
%14 = sext i1 %13 to i32
%15 = add nsw i32 %5, 1
%16 = add nsw i32 %15, %14
%17 = icmp slt i32 %16, %1
br i1 %17, label %4, label %18
18: ; preds = %4, %2
ret void
}