#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__ isspace(unsigned char const);
void trim_whitespace(const void *vpx, unsigned *offset, unsigned length) {
  const unsigned char *px = (const unsigned char *)vpx;
  while (*offset < length && isspace(px[*offset]))
    (*offset)++;
}


x86 assembly (clang, -O0):
<trim_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x21(%rbp)
jae    115c <trim_whitespace+0x4c>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    116c <trim_whitespace+0x5c>
jmp    117c <trim_whitespace+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    112b <trim_whitespace+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_whitespace>:
push   %rbp
push   %r14
push   %rbx
mov    (%rsi),%eax
cmp    %edx,%eax
jae    114c <trim_whitespace+0x3c>
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%eax
movzbl (%r14,%rax,1),%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     114c <trim_whitespace+0x3c>
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
cmp    %ebp,%eax
jb     1130 <trim_whitespace+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @trim_whitespace(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %25, %3
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = load i32, i32* %6
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i8*, i8** %7
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = load i8, i8* %19
%21 = call i64 @isspace(i8 zeroext %20)
%22 = icmp ne i64 %21, 0
br label %23
23: ; preds = %14, %9
%24 = phi i1 [ false, %9 ], [ %22, %14 ]
br i1 %24, label %25, label %29
25: ; preds = %23
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = add i32 %27, 1
store i32 %28, i32* %26
br label %9
29: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @trim_whitespace(i8* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = icmp ult i32 %4, %2
br i1 %5, label %6, label %17
6: ; preds = %3, %13
%7 = phi i32 [ %15, %13 ], [ %4, %3 ]
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 zeroext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %6
%14 = load i32, i32* %1
%15 = add i32 %14, 1
store i32 %15, i32* %1
%16 = icmp ult i32 %15, %2
br i1 %16, label %6, label %17
17: ; preds = %6, %13, %3
ret void
}