#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ print_line(char *, char *, char *);
char *trim_clean(char *);
int main() {
  FILE *output;
  char buf[256];
  output = popen("/usr/sbin/ipmitool sensor", "r");
  while (NULL != fgets(buf, sizeof(buf), output)) {
    char *col1, *col2, *col3, *col4, *cp;
    cp = buf;
    do {
      col1 = cp;
      while (*cp && *cp != '|')
        cp++;
      if (!cp)
        continue;
      *cp++ = '\0';
    } while (0);
    do {
      col2 = cp;
      while (*cp && *cp != '|')
        cp++;
      if (!cp)
        continue;
      *cp++ = '\0';
    } while (0);
    do {
      col3 = cp;
      while (*cp && *cp != '|')
        cp++;
      if (!cp)
        continue;
      *cp++ = '\0';
    } while (0);
    do {
      col4 = cp;
      while (*cp && *cp != '|')
        cp++;
      if (!cp)
        continue;
      *cp++ = '\0';
    } while (0);
    col1 = trim_clean(col1);
    col2 = trim_clean(col2);
    col4 = trim_clean(col4);
    cp = col1;
    while (*cp) {
      if (isspace(*cp))
        *cp = ':';
      cp++;
    }
    print_line(col1, "value", col2);
    print_line(col1, "status", col4);
  }
  pclose(output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     14e3 <main+0x383>
lea    -0x110(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x138(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x139(%rbp)
je     11f9 <main+0x99>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
setne  %al
mov    %al,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    120c <main+0xac>
jmp    1223 <main+0xc3>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    11c8 <main+0x68>
cmpq   $0x0,-0x138(%rbp)
jne    1236 <main+0xd6>
jmp    124e <main+0xee>
mov    -0x138(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x138(%rbp)
movb   $0x0,(%rax)
jmp    1253 <main+0xf3>
mov    -0x138(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x138(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13a(%rbp)
je     1292 <main+0x132>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
setne  %al
mov    %al,-0x13a(%rbp)
mov    -0x13a(%rbp),%al
test   $0x1,%al
jne    12a5 <main+0x145>
jmp    12bc <main+0x15c>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    1261 <main+0x101>
cmpq   $0x0,-0x138(%rbp)
jne    12cf <main+0x16f>
jmp    12e7 <main+0x187>
mov    -0x138(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x138(%rbp)
movb   $0x0,(%rax)
jmp    12ec <main+0x18c>
mov    -0x138(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x138(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13b(%rbp)
je     132b <main+0x1cb>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
setne  %al
mov    %al,-0x13b(%rbp)
mov    -0x13b(%rbp),%al
test   $0x1,%al
jne    133e <main+0x1de>
jmp    1355 <main+0x1f5>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    12fa <main+0x19a>
cmpq   $0x0,-0x138(%rbp)
jne    1368 <main+0x208>
jmp    1380 <main+0x220>
mov    -0x138(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x138(%rbp)
movb   $0x0,(%rax)
jmp    1385 <main+0x225>
mov    -0x138(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x138(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13c(%rbp)
je     13c4 <main+0x264>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
setne  %al
mov    %al,-0x13c(%rbp)
mov    -0x13c(%rbp),%al
test   $0x1,%al
jne    13d7 <main+0x277>
jmp    13ee <main+0x28e>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    1393 <main+0x233>
cmpq   $0x0,-0x138(%rbp)
jne    1401 <main+0x2a1>
jmp    1419 <main+0x2b9>
mov    -0x138(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x138(%rbp)
movb   $0x0,(%rax)
mov    -0x118(%rbp),%rdi
call   1050 <trim_clean@plt>
mov    %rax,-0x118(%rbp)
mov    -0x120(%rbp),%rdi
call   1050 <trim_clean@plt>
mov    %rax,-0x120(%rbp)
mov    -0x130(%rbp),%rdi
call   1050 <trim_clean@plt>
mov    %rax,-0x130(%rbp)
mov    -0x118(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rax
cmpb   $0x0,(%rax)
je     14aa <main+0x34a>
mov    -0x138(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     1493 <main+0x333>
mov    -0x138(%rbp),%rax
movb   $0x3a,(%rax)
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    1460 <main+0x300>
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rdx
lea    0xb5b(%rip),%rsi
call   1030 <print_line@plt>
mov    -0x118(%rbp),%rdi
mov    -0x130(%rbp),%rdx
lea    0xb47(%rip),%rsi
call   1030 <print_line@plt>
jmp    1189 <main+0x29>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe88(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,%r14
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12f9 <main+0x199>
mov    %r13,%rbx
jmp    11f0 <main+0x90>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
lea    0xe60(%rip),%rsi
mov    %rbp,%rdx
call   1030 <print_line@plt>
mov    %r15,%rdi
lea    0xe54(%rip),%rsi
mov    %rbx,%rdx
call   1030 <print_line@plt>
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %r13,%rbx
test   %rax,%rax
je     12f9 <main+0x199>
mov    (%rbx),%al
test   %al,%al
je     11fe <main+0x9e>
cmp    $0x7c,%al
jne    12f0 <main+0x190>
lea    0x1(%rbx),%rbp
movb   $0x0,(%rbx)
add    $0x2,%rbx
mov    %rbp,%rax
nopl   0x0(%rax)
movzbl (%rax),%ecx
test   %cl,%cl
je     1230 <main+0xd0>
cmp    $0x7c,%cl
je     1230 <main+0xd0>
add    $0x1,%rax
add    $0x1,%rbx
jmp    1210 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x7c,%al
je     124f <main+0xef>
test   %al,%al
jne    1240 <main+0xe0>
movb   $0x0,-0x1(%rbx)
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1280 <main+0x120>
cmp    $0x7c,%cl
je     1280 <main+0x120>
add    $0x1,%rax
jmp    1260 <main+0x100>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,(%rax)
mov    %r13,%rdi
call   1050 <trim_clean@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1050 <trim_clean@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <trim_clean@plt>
mov    %rax,%rbx
mov    (%r15),%al
test   %al,%al
je     11b0 <main+0x50>
lea    0x1(%r15),%r12
jmp    12d1 <main+0x171>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r12),%eax
add    $0x1,%r12
test   %al,%al
je     11b0 <main+0x50>
movsbl %al,%edi
call   1060 <isspace@plt>
test   %rax,%rax
je     12c0 <main+0x160>
movb   $0x3a,-0x1(%r12)
jmp    12c0 <main+0x160>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
jmp    11f0 <main+0x90>
mov    %r14,%rdi
call   1040 <pclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"/usr/sbin/ipmitool sensor\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"value\00"
@.str.3 = [7 x i8] c"status\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
%9 = call i32* @popen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
br label %10
10: ; preds = %138, %0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32* @fgets(i8* %11, i32 256, i32* %12)
%14 = icmp ne i32* null, %13
br i1 %14, label %15, label %145
15: ; preds = %10
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8* %16, i8** %8
br label %17
17: ; preds = %15
%18 = load i8*, i8** %8
store i8* %18, i8** %4
br label %19
19: ; preds = %31, %17
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 124
br label %29
29: ; preds = %24, %19
%30 = phi i1 [ false, %19 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %8
br label %19
34: ; preds = %29
%35 = load i8*, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %38, label %37
37: ; preds = %34
br label %41
38: ; preds = %34
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %8
store i8 0, i8* %39
br label %41
41: ; preds = %37, %38
br label %42
42: ; preds = %41
%43 = load i8*, i8** %8
store i8* %43, i8** %5
br label %44
44: ; preds = %56, %42
%45 = load i8*, i8** %8
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = load i8*, i8** %8
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 124
br label %54
54: ; preds = %49, %44
%55 = phi i1 [ false, %44 ], [ %53, %49 ]
br i1 %55, label %56, label %59
56: ; preds = %54
%57 = load i8*, i8** %8
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %8
br label %44
59: ; preds = %54
%60 = load i8*, i8** %8
%61 = icmp ne i8* %60, null
br i1 %61, label %63, label %62
62: ; preds = %59
br label %66
63: ; preds = %59
%64 = load i8*, i8** %8
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %8
store i8 0, i8* %64
br label %66
66: ; preds = %62, %63
br label %67
67: ; preds = %66
%68 = load i8*, i8** %8
store i8* %68, i8** %6
br label %69
69: ; preds = %81, %67
%70 = load i8*, i8** %8
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %69
%75 = load i8*, i8** %8
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp ne i32 %77, 124
br label %79
79: ; preds = %74, %69
%80 = phi i1 [ false, %69 ], [ %78, %74 ]
br i1 %80, label %81, label %84
81: ; preds = %79
%82 = load i8*, i8** %8
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %8
br label %69
84: ; preds = %79
%85 = load i8*, i8** %8
%86 = icmp ne i8* %85, null
br i1 %86, label %88, label %87
87: ; preds = %84
br label %91
88: ; preds = %84
%89 = load i8*, i8** %8
%90 = getelementptr inbounds i8, i8* %89, i32 1
store i8* %90, i8** %8
store i8 0, i8* %89
br label %91
91: ; preds = %87, %88
br label %92
92: ; preds = %91
%93 = load i8*, i8** %8
store i8* %93, i8** %7
br label %94
94: ; preds = %106, %92
%95 = load i8*, i8** %8
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %94
%100 = load i8*, i8** %8
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp ne i32 %102, 124
br label %104
104: ; preds = %99, %94
%105 = phi i1 [ false, %94 ], [ %103, %99 ]
br i1 %105, label %106, label %109
106: ; preds = %104
%107 = load i8*, i8** %8
%108 = getelementptr inbounds i8, i8* %107, i32 1
store i8* %108, i8** %8
br label %94
109: ; preds = %104
%110 = load i8*, i8** %8
%111 = icmp ne i8* %110, null
br i1 %111, label %113, label %112
112: ; preds = %109
br label %116
113: ; preds = %109
%114 = load i8*, i8** %8
%115 = getelementptr inbounds i8, i8* %114, i32 1
store i8* %115, i8** %8
store i8 0, i8* %114
br label %116
116: ; preds = %112, %113
%117 = load i8*, i8** %4
%118 = call i8* @trim_clean(i8* %117)
store i8* %118, i8** %4
%119 = load i8*, i8** %5
%120 = call i8* @trim_clean(i8* %119)
store i8* %120, i8** %5
%121 = load i8*, i8** %7
%122 = call i8* @trim_clean(i8* %121)
store i8* %122, i8** %7
%123 = load i8*, i8** %4
store i8* %123, i8** %8
br label %124
124: ; preds = %135, %116
%125 = load i8*, i8** %8
%126 = load i8, i8* %125
%127 = icmp ne i8 %126, 0
br i1 %127, label %128, label %138
128: ; preds = %124
%129 = load i8*, i8** %8
%130 = load i8, i8* %129
%131 = call i64 @isspace(i8 signext %130)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %135
133: ; preds = %128
%134 = load i8*, i8** %8
store i8 58, i8* %134
br label %135
135: ; preds = %133, %128
%136 = load i8*, i8** %8
%137 = getelementptr inbounds i8, i8* %136, i32 1
store i8* %137, i8** %8
br label %124
138: ; preds = %124
%139 = load i8*, i8** %4
%140 = load i8*, i8** %5
%141 = call i32 @print_line(i8* %139, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %140)
%142 = load i8*, i8** %4
%143 = load i8*, i8** %7
%144 = call i32 @print_line(i8* %142, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %143)
br label %10
145: ; preds = %10
%146 = load i32*, i32** %2
%147 = call i32 @pclose(i32* %146)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"/usr/sbin/ipmitool sensor\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"value\00"
@.str.3 = [7 x i8] c"status\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @popen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32* @fgets(i8* %2, i32 256, i32* %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %53, label %6
6: ; preds = %0, %11
%7 = phi i8* [ %12, %11 ], [ %2, %0 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %13
i8 124, label %13
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %11
11: ; preds = %9, %48
%12 = phi i8* [ %10, %9 ], [ %2, %48 ]
br label %6
13: ; preds = %6, %6
%14 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
br label %15
15: ; preds = %18, %13
%16 = phi i8* [ %14, %13 ], [ %19, %18 ]
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 0, label %20
i8 124, label %20
]
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %16, i64 1
br label %15
20: ; preds = %15, %15
store i8 0, i8* %16
br label %21
21: ; preds = %21, %20
%22 = phi i8* [ %16, %20 ], [ %23, %21 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
switch i8 %24, label %21 [
i8 0, label %25
i8 124, label %25
]
25: ; preds = %21, %21
%26 = getelementptr inbounds i8, i8* %22, i64 2
store i8 0, i8* %23
br label %27
27: ; preds = %30, %25
%28 = phi i8* [ %26, %25 ], [ %31, %30 ]
%29 = load i8, i8* %28
switch i8 %29, label %30 [
i8 0, label %32
i8 124, label %32
]
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %28, i64 1
br label %27
32: ; preds = %27, %27
store i8 0, i8* %28
%33 = call i8* @trim_clean(i8* %2)
%34 = call i8* @trim_clean(i8* %14)
%35 = call i8* @trim_clean(i8* %26)
%36 = load i8, i8* %33
%37 = icmp eq i8 %36, 0
br i1 %37, label %48, label %38
38: ; preds = %32, %44
%39 = phi i8 [ %46, %44 ], [ %36, %32 ]
%40 = phi i8* [ %45, %44 ], [ %33, %32 ]
%41 = call i64 @isspace(i8 signext %39)
%42 = icmp eq i64 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38
store i8 58, i8* %40
br label %44
44: ; preds = %43, %38
%45 = getelementptr inbounds i8, i8* %40, i64 1
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %38
48: ; preds = %44, %32
%49 = call i32 @print_line(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%50 = call i32 @print_line(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%51 = call i32* @fgets(i8* %2, i32 256, i32* %3)
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %11
53: ; preds = %48, %0
%54 = call i32 @pclose(i32* %3)
ret i32 0
}