#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);
char *skip_spaces(char *);
int strlen(char *);
char *yml_parser_get_str(char *line) {
  char *pnt;
  char *str;
  str = skip_spaces(line);
  if (*str == 0) {
    return NULL;
  }
  pnt = str + strlen(str) - 1U;
  while (isspace((unsigned char)*pnt)) {
    *pnt-- = 0;
  }
  if (*pnt == 0) {
    return NULL;
  }
  return str;
}


x86 assembly (clang, -O0):
<yml_parser_get_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <skip_spaces@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1166 <yml_parser_get_str+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11dd <yml_parser_get_str+0xad>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11b8 <yml_parser_get_str+0x88>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    118b <yml_parser_get_str+0x5b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d5 <yml_parser_get_str+0xa5>
movq   $0x0,-0x8(%rbp)
jmp    11dd <yml_parser_get_str+0xad>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yml_parser_get_str>:
push   %r14
push   %rbx
push   %rax
call   1050 <skip_spaces@plt>
cmpb   $0x0,(%rax)
je     1182 <yml_parser_get_str+0x52>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
add    $0xffffffffffffffff,%rbx
movzbl -0x1(%r14,%rax,1),%edi
nopl   0x0(%rax)
call   1040 <isspace@plt>
test   %rax,%rax
je     1177 <yml_parser_get_str+0x47>
movb   $0x0,(%rbx)
movzbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
jmp    1160 <yml_parser_get_str+0x30>
xor    %eax,%eax
cmpb   $0x0,(%rbx)
cmove  %rax,%r14
jmp    1185 <yml_parser_get_str+0x55>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @yml_parser_get_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @skip_spaces(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i8* null, i8** %2
br label %36
13: ; preds = %1
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -1
store i8* %19, i8** %4
br label %20
20: ; preds = %25, %13
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = call i64 @isspace(i8 zeroext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 -1
store i8* %27, i8** %4
store i8 0, i8* %26
br label %20
28: ; preds = %20
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i8* null, i8** %2
br label %36
34: ; preds = %28
%35 = load i8*, i8** %5
store i8* %35, i8** %2
br label %36
36: ; preds = %34, %33, %12
%37 = load i8*, i8** %2
ret i8* %37
}

LLVM IR (-O2):
define i8* @yml_parser_get_str(i8* %0) {
%2 = tail call i8* @skip_spaces(i8* %0)
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %24, label %5
5: ; preds = %1
%6 = tail call i32 @strlen(i8* %2)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 zeroext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %5, %13
%14 = phi i8* [ %15, %13 ], [ %9, %5 ]
store i8 0, i8* %14
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = load i8, i8* %15
%17 = tail call i64 @isspace(i8 zeroext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %13
19: ; preds = %13, %5
%20 = phi i8* [ %9, %5 ], [ %15, %13 ]
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
%23 = select i1 %22, i8* null, i8* %2
br label %24
24: ; preds = %19, %1
%25 = phi i8* [ null, %1 ], [ %23, %19 ]
ret i8* %25
}