#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*/ free(char *);
int getdelim(char **, size_t *, char, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *get_one_frobbed(void) {
  char *line = NULL;
  size_t capacity = 0;
  int r = getdelim(&line, &capacity, ' ', stdin);
  if (r > 0) {
    if (line[r - 1] != ' ') {
      line[r] = ' ';
    }
    return line;
  } else {
    free(line);
    return NULL;
  }
}


x86 assembly (clang, -O0):
<get_one_frobbed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%ecx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x20,%edx
call   1040 <getdelim@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1193 <get_one_frobbed+0x73>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1186 <get_one_frobbed+0x66>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <get_one_frobbed+0x84>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_one_frobbed>:
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x20,%edx
call   1040 <getdelim@plt>
mov    %eax,%ecx
mov    0x8(%rsp),%rax
test   %ecx,%ecx
jle    1177 <get_one_frobbed+0x57>
lea    -0x1(%rcx),%edx
cmpb   $0x20,(%rax,%rdx,1)
je     1181 <get_one_frobbed+0x61>
mov    %ecx,%ecx
movb   $0x20,(%rax,%rcx,1)
mov    0x8(%rsp),%rax
add    $0x18,%rsp
ret
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i8* @get_one_frobbed() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i8* null, i8** %2
store i64 0, i64* %3
%5 = load i32, i32* @stdin
%6 = call i32 @getdelim(i8** %2, i64* %3, i8 signext 32, i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 32
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 32, i8* %22
br label %23
23: ; preds = %18, %9
%24 = load i8*, i8** %2
store i8* %24, i8** %1
br label %28
25: ; preds = %0
%26 = load i8*, i8** %2
%27 = call i32 @free(i8* %26)
store i8* null, i8** %1
br label %28
28: ; preds = %25, %23
%29 = load i8*, i8** %1
ret i8* %29
}

LLVM IR (-O2):
@stdin = global i32 0
define i8* @get_one_frobbed() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = load i32, i32* @stdin
%6 = call i32 @getdelim(i8** %1, i64* %2, i8 signext 32, i32 %5)
%7 = icmp sgt i32 %6, 0
%8 = load i8*, i8** %1
br i1 %7, label %9, label %19
9: ; preds = %0
%10 = add nsw i32 %6, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %21, label %15
15: ; preds = %9
%16 = zext i32 %6 to i64
%17 = getelementptr inbounds i8, i8* %8, i64 %16
store i8 32, i8* %17
%18 = load i8*, i8** %1
br label %21
19: ; preds = %0
%20 = call i32 @free(i8* %8)
br label %21
21: ; preds = %9, %15, %19
%22 = phi i8* [ null, %19 ], [ %18, %15 ], [ %8, %9 ]
ret i8* %22
}