#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 find_char_offset(char *, char);
int strlen(char *);
void select_display_start_and_end(char *string, char mode, int wrap_offset,
                                  int win_width, int *prt_start, int *prt_end,
                                  int *disp_end) {
  int nbytes = strlen(string);
  *prt_start = 0;
  *prt_end = nbytes;
  *disp_end = nbytes;
  if (mode == 'a') {
    *disp_end = -1;
  } else if (mode == 'l') {
    *prt_start = ((wrap_offset) < (nbytes) ? (wrap_offset) : (nbytes));
    *prt_end =
        ((nbytes) < (win_width + wrap_offset) ? (nbytes)
                                              : (win_width + wrap_offset));
    *disp_end = ((win_width) < (nbytes - *prt_start) ? (win_width)
                                                     : (nbytes - *prt_start));
  } else if (mode == 'r') {
    *prt_start = ((0) > (nbytes - win_width) ? (0) : (nbytes - win_width));
    *disp_end = win_width;
  } else if (mode == 'S') {
    *prt_start = find_char_offset(string, ':');
    if (*prt_start == -1)
      *prt_start = 0;
    *disp_end = nbytes - *prt_start;
  } else if (mode == 's') {
    if (nbytes > 16)
      *prt_start = find_char_offset(&string[16], ' ');
    else
      *prt_start = -1;
    if (*prt_start == -1)
      *prt_start = 0;
    *disp_end = nbytes - *prt_start;
  } else if (mode == 'o') {
    *prt_start = ((wrap_offset) < (nbytes) ? (wrap_offset) : (nbytes));
    *disp_end = nbytes - *prt_start;
  }
}


x86 assembly (clang, -O0):
<select_display_start_and_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    0x10(%rbp),%rsi
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
movsbl -0x9(%rbp),%eax
cmp    $0x61,%eax
jne    1188 <select_display_start_and_end+0x68>
mov    0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    137d <select_display_start_and_end+0x25d>
movsbl -0x9(%rbp),%eax
cmp    $0x6c,%eax
jne    1222 <select_display_start_and_end+0x102>
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11ac <select_display_start_and_end+0x8c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    11b2 <select_display_start_and_end+0x92>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11d7 <select_display_start_and_end+0xb7>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11e0 <select_display_start_and_end+0xc0>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
jge    1208 <select_display_start_and_end+0xe8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1214 <select_display_start_and_end+0xf4>
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1378 <select_display_start_and_end+0x258>
movsbl -0x9(%rbp),%eax
cmp    $0x72,%eax
jne    1269 <select_display_start_and_end+0x149>
mov    -0x2c(%rbp),%ecx
sub    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jle    1249 <select_display_start_and_end+0x129>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    1252 <select_display_start_and_end+0x132>
mov    -0x2c(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1373 <select_display_start_and_end+0x253>
movsbl -0x9(%rbp),%eax
cmp    $0x53,%eax
jne    12b7 <select_display_start_and_end+0x197>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <find_char_offset@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    12a3 <select_display_start_and_end+0x183>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
sub    (%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    136e <select_display_start_and_end+0x24e>
movsbl -0x9(%rbp),%eax
cmp    $0x73,%eax
jne    1322 <select_display_start_and_end+0x202>
cmpl   $0x10,-0x2c(%rbp)
jle    12ed <select_display_start_and_end+0x1cd>
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
mov    $0x20,%esi
call   1040 <find_char_offset@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12f7 <select_display_start_and_end+0x1d7>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    130e <select_display_start_and_end+0x1ee>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
sub    (%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1369 <select_display_start_and_end+0x249>
movsbl -0x9(%rbp),%eax
cmp    $0x6f,%eax
jne    1364 <select_display_start_and_end+0x244>
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1346 <select_display_start_and_end+0x226>
mov    -0x10(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    134c <select_display_start_and_end+0x22c>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
sub    (%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1369 <select_display_start_and_end+0x249>
jmp    136e <select_display_start_and_end+0x24e>
jmp    1373 <select_display_start_and_end+0x253>
jmp    1378 <select_display_start_and_end+0x258>
jmp    137d <select_display_start_and_end+0x25d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_display_start_and_end>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r12
mov    %r8,%r14
mov    %ecx,0x4(%rsp)
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r13
mov    0x40(%rsp),%rbx
call   1030 <strlen@plt>
mov    %rbx,%rsi
movl   $0x0,(%r14)
mov    %eax,(%r12)
mov    %eax,(%rbx)
add    $0xad,%r15b
cmp    $0x20,%r15b
ja     11ff <select_display_start_and_end+0xdf>
mov    %eax,%ebx
mov    $0xffffffff,%eax
movzbl %r15b,%ecx
lea    0xe89(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    %r13,%rdi
mov    %rsi,%rbp
mov    $0x3a,%esi
call   1040 <find_char_offset@plt>
mov    %rbp,%rsi
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
cmovne %eax,%ecx
mov    %ecx,(%r14)
sub    %ecx,%ebx
jmp    11fb <select_display_start_and_end+0xdb>
cmp    %ebp,%ebx
mov    %ebx,%eax
cmovg  %ebp,%eax
mov    %eax,(%r14)
mov    0x4(%rsp),%ecx
add    %ecx,%ebp
cmp    %ebp,%ebx
cmovl  %ebx,%ebp
mov    %ebp,(%r12)
mov    (%r14),%eax
sub    %eax,%ebx
cmp    %ecx,%ebx
cmovg  %ecx,%ebx
jmp    11fb <select_display_start_and_end+0xdb>
cmp    $0x11,%ebx
jl     11e8 <select_display_start_and_end+0xc8>
add    $0x10,%r13
mov    %r13,%rdi
mov    %rsi,%rbp
mov    $0x20,%esi
call   1040 <find_char_offset@plt>
mov    %rbp,%rsi
cmp    $0xffffffff,%eax
jne    11ea <select_display_start_and_end+0xca>
xor    %eax,%eax
mov    %eax,(%r14)
sub    %eax,%ebx
jmp    11fb <select_display_start_and_end+0xdb>
cmp    %ebp,%ebx
cmovle %ebx,%ebp
mov    %ebp,(%r14)
sub    %ebp,%ebx
mov    %ebx,%eax
mov    %eax,(%rsi)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
mov    0x4(%rsp),%ecx
sub    %ecx,%ebx
cmovs  %eax,%ebx
mov    %ebx,(%r14)
mov    %ecx,%eax
jmp    11fd <select_display_start_and_end+0xdd>

LLVM IR (-O0):
define void @select_display_start_and_end(i8* %0, i8 signext %1, i32 %2, i32 %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i8* %0, i8** %8
store i8 %1, i8* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%16 = load i8*, i8** %8
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %15
%18 = load i32*, i32** %12
store i32 0, i32* %18
%19 = load i32, i32* %15
%20 = load i32*, i32** %13
store i32 %19, i32* %20
%21 = load i32, i32* %15
%22 = load i32*, i32** %14
store i32 %21, i32* %22
%23 = load i8, i8* %9
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 97
br i1 %25, label %26, label %28
26: ; preds = %7
%27 = load i32*, i32** %14
store i32 -1, i32* %27
br label %162
28: ; preds = %7
%29 = load i8, i8* %9
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 108
br i1 %31, label %32, label %73
32: ; preds = %28
%33 = load i32, i32* %10
%34 = load i32, i32* %15
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %10
br label %40
38: ; preds = %32
%39 = load i32, i32* %15
br label %40
40: ; preds = %38, %36
%41 = phi i32 [ %37, %36 ], [ %39, %38 ]
%42 = load i32*, i32** %12
store i32 %41, i32* %42
%43 = load i32, i32* %15
%44 = load i32, i32* %11
%45 = load i32, i32* %10
%46 = add nsw i32 %44, %45
%47 = icmp slt i32 %43, %46
br i1 %47, label %48, label %50
48: ; preds = %40
%49 = load i32, i32* %15
br label %54
50: ; preds = %40
%51 = load i32, i32* %11
%52 = load i32, i32* %10
%53 = add nsw i32 %51, %52
br label %54
54: ; preds = %50, %48
%55 = phi i32 [ %49, %48 ], [ %53, %50 ]
%56 = load i32*, i32** %13
store i32 %55, i32* %56
%57 = load i32, i32* %11
%58 = load i32, i32* %15
%59 = load i32*, i32** %12
%60 = load i32, i32* %59
%61 = sub nsw i32 %58, %60
%62 = icmp slt i32 %57, %61
br i1 %62, label %63, label %65
63: ; preds = %54
%64 = load i32, i32* %11
br label %70
65: ; preds = %54
%66 = load i32, i32* %15
%67 = load i32*, i32** %12
%68 = load i32, i32* %67
%69 = sub nsw i32 %66, %68
br label %70
70: ; preds = %65, %63
%71 = phi i32 [ %64, %63 ], [ %69, %65 ]
%72 = load i32*, i32** %14
store i32 %71, i32* %72
br label %161
73: ; preds = %28
%74 = load i8, i8* %9
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 114
br i1 %76, label %77, label %92
77: ; preds = %73
%78 = load i32, i32* %15
%79 = load i32, i32* %11
%80 = sub nsw i32 %78, %79
%81 = icmp sgt i32 0, %80
br i1 %81, label %82, label %83
82: ; preds = %77
br label %87
83: ; preds = %77
%84 = load i32, i32* %15
%85 = load i32, i32* %11
%86 = sub nsw i32 %84, %85
br label %87
87: ; preds = %83, %82
%88 = phi i32 [ 0, %82 ], [ %86, %83 ]
%89 = load i32*, i32** %12
store i32 %88, i32* %89
%90 = load i32, i32* %11
%91 = load i32*, i32** %14
store i32 %90, i32* %91
br label %160
92: ; preds = %73
%93 = load i8, i8* %9
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 83
br i1 %95, label %96, label %111
96: ; preds = %92
%97 = load i8*, i8** %8
%98 = call i32 @find_char_offset(i8* %97, i8 signext 58)
%99 = load i32*, i32** %12
store i32 %98, i32* %99
%100 = load i32*, i32** %12
%101 = load i32, i32* %100
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %105
103: ; preds = %96
%104 = load i32*, i32** %12
store i32 0, i32* %104
br label %105
105: ; preds = %103, %96
%106 = load i32, i32* %15
%107 = load i32*, i32** %12
%108 = load i32, i32* %107
%109 = sub nsw i32 %106, %108
%110 = load i32*, i32** %14
store i32 %109, i32* %110
br label %159
111: ; preds = %92
%112 = load i8, i8* %9
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 115
br i1 %114, label %115, label %137
115: ; preds = %111
%116 = load i32, i32* %15
%117 = icmp sgt i32 %116, 16
br i1 %117, label %118, label %123
118: ; preds = %115
%119 = load i8*, i8** %8
%120 = getelementptr inbounds i8, i8* %119, i64 16
%121 = call i32 @find_char_offset(i8* %120, i8 signext 32)
%122 = load i32*, i32** %12
store i32 %121, i32* %122
br label %125
123: ; preds = %115
%124 = load i32*, i32** %12
store i32 -1, i32* %124
br label %125
125: ; preds = %123, %118
%126 = load i32*, i32** %12
%127 = load i32, i32* %126
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = load i32*, i32** %12
store i32 0, i32* %130
br label %131
131: ; preds = %129, %125
%132 = load i32, i32* %15
%133 = load i32*, i32** %12
%134 = load i32, i32* %133
%135 = sub nsw i32 %132, %134
%136 = load i32*, i32** %14
store i32 %135, i32* %136
br label %158
137: ; preds = %111
%138 = load i8, i8* %9
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 111
br i1 %140, label %141, label %157
141: ; preds = %137
%142 = load i32, i32* %10
%143 = load i32, i32* %15
%144 = icmp slt i32 %142, %143
br i1 %144, label %145, label %147
145: ; preds = %141
%146 = load i32, i32* %10
br label %149
147: ; preds = %141
%148 = load i32, i32* %15
br label %149
149: ; preds = %147, %145
%150 = phi i32 [ %146, %145 ], [ %148, %147 ]
%151 = load i32*, i32** %12
store i32 %150, i32* %151
%152 = load i32, i32* %15
%153 = load i32*, i32** %12
%154 = load i32, i32* %153
%155 = sub nsw i32 %152, %154
%156 = load i32*, i32** %14
store i32 %155, i32* %156
br label %157
157: ; preds = %149, %137
br label %158
158: ; preds = %157, %131
br label %159
159: ; preds = %158, %105
br label %160
160: ; preds = %159, %87
br label %161
161: ; preds = %160, %70
br label %162
162: ; preds = %161, %26
ret void
}

LLVM IR (-O2):
define void @select_display_start_and_end(i8* %0, i8 signext %1, i32 %2, i32 %3, i32* nocapture %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = tail call i32 @strlen(i8* %0)
store i32 0, i32* %4
store i32 %8, i32* %5
store i32 %8, i32* %6
switch i8 %1, label %44 [
i8 97, label %42
i8 108, label %9
i8 114, label %19
i8 83, label %23
i8 115, label %28
i8 111, label %38
]
9: ; preds = %7
%10 = icmp sgt i32 %8, %2
%11 = select i1 %10, i32 %2, i32 %8
store i32 %11, i32* %4
%12 = add nsw i32 %3, %2
%13 = icmp slt i32 %8, %12
%14 = select i1 %13, i32 %8, i32 %12
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = sub nsw i32 %8, %15
%17 = icmp sgt i32 %16, %3
%18 = select i1 %17, i32 %3, i32 %16
br label %42
19: ; preds = %7
%20 = sub nsw i32 %8, %3
%21 = icmp sgt i32 %20, 0
%22 = select i1 %21, i32 %20, i32 0
store i32 %22, i32* %4
br label %42
23: ; preds = %7
%24 = tail call i32 @find_char_offset(i8* %0, i8 signext 58)
%25 = icmp eq i32 %24, -1
%26 = select i1 %25, i32 0, i32 %24
store i32 %26, i32* %4
%27 = sub nsw i32 %8, %26
br label %42
28: ; preds = %7
%29 = icmp sgt i32 %8, 16
br i1 %29, label %30, label %34
30: ; preds = %28
%31 = getelementptr inbounds i8, i8* %0, i64 16
%32 = tail call i32 @find_char_offset(i8* %31, i8 signext 32)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %35
34: ; preds = %28, %30
br label %35
35: ; preds = %30, %34
%36 = phi i32 [ 0, %34 ], [ %32, %30 ]
store i32 %36, i32* %4
%37 = sub nsw i32 %8, %36
br label %42
38: ; preds = %7
%39 = icmp sgt i32 %8, %2
%40 = select i1 %39, i32 %2, i32 %8
store i32 %40, i32* %4
%41 = sub nsw i32 %8, %40
br label %42
42: ; preds = %7, %19, %35, %38, %23, %9
%43 = phi i32 [ %18, %9 ], [ %27, %23 ], [ %41, %38 ], [ %37, %35 ], [ %3, %19 ], [ -1, %7 ]
store i32 %43, i32* %6
br label %44
44: ; preds = %42, %7
ret void
}