#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*/ abort();
int /*<<< orphan*/ isspace(char);
void tm_get_strlen_(int *len_str, int *whole_len, char *in_string) {
  int i;
  if (in_string == NULL)
    abort();
  for (i = *whole_len - 1; i >= 0; i--) {
    if (!isspace(in_string[i]))
      break;
  }
  *len_str = i + 1;
  return;
}


x86 assembly (clang, -O0):
<tm_get_strlen_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1146 <tm_get_strlen_+0x26>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     118e <tm_get_strlen_+0x6e>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    117b <tm_get_strlen_+0x5b>
jmp    118e <tm_get_strlen_+0x6e>
jmp    1180 <tm_get_strlen_+0x60>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <tm_get_strlen_+0x32>
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_get_strlen_>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
je     116a <tm_get_strlen_+0x4a>
mov    %rdx,%r15
mov    %rdi,%r14
mov    (%rsi),%ebx
xor    %ebp,%ebp
test   %ebx,%ebx
cmovs  %ebx,%ebp
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
jle    115c <tm_get_strlen_+0x3c>
movsbl -0x1(%r15,%rbx,1),%edi
call   1040 <isspace@plt>
add    $0xffffffffffffffff,%rbx
test   %eax,%eax
jne    1140 <tm_get_strlen_+0x20>
add    $0x1,%ebx
mov    %ebx,%ebp
mov    %ebp,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define void @tm_get_strlen_(i32* nocapture writeonly %0, i32* nocapture %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %3
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = call i32 @llvm.smin.i32(i32 %8, i32 0)
br label %11
11: ; preds = %16, %7
%12 = phi i64 [ %13, %16 ], [ %9, %7 ]
%13 = add nsw i64 %12, -1
%14 = trunc i64 %12 to i32
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %2, i64 %13
%18 = load i8, i8* %17
%19 = tail call i32 @isspace(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %16
%22 = trunc i64 %12 to i32
br label %23
23: ; preds = %11, %21
%24 = phi i32 [ %22, %21 ], [ %10, %11 ]
store i32 %24, i32* %0
ret void
}